Twitter android SDK OAuth Login: "Twitter: Authorize not in progress"

android
oauth

#1

We are using com.twitter.sdk.android:twitter:1.8.0 android SDK for login.

From an Activity we are initiating the login authorize request. While clicking on login button, SDK automatically redirects to Twitter app for authentication. After user press “Allow” on the twitter page, application receives via onActivityResult. It works perfectly most of the time. But it was failing randomly. Following are the observations:

  1. When i click on login, Twitter app is getting launched. At that time, due to low memory situations, our app is getting killed.
  2. Once user gives permission our app is relaunched. As activity itself recreated, twitterauthclient object also recreated.

mTwitterAuthClient= new TwitterAuthClient();

3.OnActivityResult we get the response data and try to invoke

mTwitterAuthClient.onActivityResult(requestCode, resultCode, data);

We get following error

Twitter: Authorize not in progress

If the acitivity is not killed, SDK works perfectly. We get this problem only if activity is getting killed.

We are able to reproduce this problem, if you set Android settings->Developer options->Don’t keep activity.


#2

(moving to the Fabric/Twitter Kit category)


#3

@AramSubramanian Thanks for reporting this - could you please share the logcat output when this happens locally?


#4

Hi @AramSubramanian, I was unable to reproduce this problem with the given instructions using our test app. This error usually occurs when onActivityResult isn’t setup correctly. Sample code can be found on TwitterKit Github page.


#5

Hi Eric,

Did you set the “Dont keep activities” developer option in android settings before running this? I have attached the snapsho. And also install twitter app in this phone. So that, while clicking on twitter login button, it will redirect us to another app and our test app will be destroyed. Once we hit accept or reject in our activity will be recreated. So eventually new activity and new login button instances are created.

I get this problem only if i set this flag. This will actually mimic the low memory cases during testing. BTW, I have fragment inside this activity. But i made sure to pass on the same object to fragment. This works well when I dont set the flag.


#6

I am very familiar with that setting. Still wasn’t able to repo. Can you share your code? Also see note on using fragments here: https://docs.fabric.io/android/twitter/authentication.html#pass-the-activity-s-result-back-to-the-button