Get "com.twitter.sdk.android.core.TwitterAuthException: Authorize failed."


#1
  1. I use TwitterAuthClient, NOT TwitterLoginButton.
  2. call authorize() of TwitterAuthClient.
  3. Press “Home” key back to Home Screen.
  4. Click the App to run it.
  5. call authorize() of TwitterAuthClient.
  6. Get exception:
    Twitter: Authorize already in progress
    Twitter: Authorization completed with an error
    com.twitter.sdk.android.core.TwitterAuthException: Authorize failed.
    at com.twitter.sdk.android.core.identity.TwitterAuthClient.handleAuthorize(TwitterAuthClient.java:110)
    at com.twitter.sdk.android.core.identity.TwitterAuthClient.authorize(TwitterAuthClient.java:101)
  7. Does anyone know how to handle this situation?
    thank you.

#2

Hey @Yvan,

Just as a heads up, I removed your other posts as duplicates.

Can you share the Logcat output you’re seeing at step 2? Also, which version of Twitter Kit are you using?


#3

Hi Bonnell,
I follow https://fabric.io/kits/android/twitterkit/install to setup Twitter Kit.
The version should be com.twitter.sdk.android:twitter:1.13.1" right?

In Step 2, it shows Twitter Login screen(like official Twitter Login screen),
but I didn’t type any account information to it, I just press “Home” key back to Home Screen.
so there are no log about TwitterAuthClient on this step.

Is there any method that can know " Authorize already in progress", then any API can end it.
I check the AuthState.java, it has endAuthorize() to end it.
But AuthState in TwitterAuthClient.java is private.


#4

Hi Yvan,

I was unable reproduce “Authorize failed” from the steps mentioned above. Can you please elaborate on what you are trying to achieve by pressing “Home” key and authorizing again? Thanks.


#5

Hi Vamsi,
You can use 2 App, one is App_A, one is App_B.
App_A has a button, click button to startActiviy() a activity of App_B.
App_B has a button, click button to run TwitterAuthClient.authorize().

The reproduce step.

  1. Run App_A , click its button.
  2. App_B’s activity is called by App_A.
  3. In App_B, click its button to call TwitterAuthClient.authorize().
  4. The Twitter Login screen appears, press Home key of device back to Home screen.
  5. Run App_B, then press Home screen.
  6. Run App_A, click its button to App_B’s activity, Click button of App_B, then exception
    Twitter: Authorize already in progress
    Twitter: Authorization completed with an error
    com.twitter.sdk.android.core.TwitterAuthException: Authorize failed.

#6

Thanks Yvan for the detailed steps. Unfortunately, we were unable to reproduce the error that you are facing. Are you are passing the result of the authentication Activity back to the button? Here is an example:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Pass the activity result to the saveSession button.
loginButton.onActivityResult(requestCode, resultCode, data);
}

More info on Twitter auth can be found here:

https://docs.fabric.io/android/twitter/authentication.html#log-in-with-twitter

If you are still having trouble, please share snippet of your app code to help us debug. Thanks.