TwitterAuthException: Authorize failed


#1

Hello, i implemented sign in with twitter using fabrick SDK in an android application and it used to work fine. But from a couple of days ago, the following error occurs when i try to log in:

E/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)
               at com.twitter.sdk.android.core.identity.TwitterLoginButton$LoginClickListener.onClick(TwitterLoginButton.java:161)
               at android.view.View.performClick(View.java:5230)
               at android.view.View$PerformClick.run(View.java:20999)
               at android.os.Handler.handleCallback(Handler.java:739)
               at android.os.Handler.dispatchMessage(Handler.java:95)
               at android.os.Looper.loop(Looper.java:145)
               at android.app.ActivityThread.main(ActivityThread.java:6117)
               at java.lang.reflect.Method.invoke(Native Method)
               at java.lang.reflect.Method.invoke(Method.java:372)
               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

I have this in OnCreate():

   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
        Fabric.with(this, new Twitter(authConfig));
        setContentView(R.layout.activity_main);
        twitterLoginButton = (TwitterLoginButton) findViewById(R.id.twitter_login_button);
        twitterLoginButton.setCallback(new Callback<TwitterSession>() {
            @Override
            public void success(Result<TwitterSession> result) {
                 session = result.data;


             @Override
             public void failure(TwitterException exception) {
                 Log.d("TwitterKit", "Login with Twitter failure", exception);

            }
    });

and this in onActivityResult():

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
               twitterLoginButton.onActivityResult(requestCode, resultCode, data);
                
        }

This error only happens when the Twitter App is installed, while it works when its the webview that pops up asking for authorization.
I tried using the Twitter key and Secret that I get when i create an app in apps.twitter and the ones that are created by Fabric.


#2

To add some more context. This only seems to happen on Android 5.0 for me when testing in emulators.

This crash is a result of a native crash from trying to animate on a null object, native stack below.

02-09 11:37:14.336 1579-2534/system_process I/ActivityManager: START u0 {cmp=com.twitter.android/com.twitter.app.authorizeapp.AppAuthorizationActivity (has extras)} from uid 10058 on display 0
02-09 11:37:14.385 3739-3739/com.twitter.android W/Resources: Converting to string: TypedValue{t=0x10/d=0xfffffffd a=2}
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: can't call void android.view.View.setTranslationZ(float) on null object
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]     in call to CallVoidMethodV
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]     from void android.animation.PropertyValuesHolder.nCallFloatMethod(java.lang.Object, long, float)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x74d86fa8 self=0x7f2ea5e97000
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   | sysTid=3739 nice=0 cgrp=apps sched=0/0 handle=0x7f2ea92046a0
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   | state=R schedstat=( 0 0 0 ) utm=82 stm=86 core=3 HZ=100
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   | stack=0x7fffee534000-0x7fffee536000 stackSize=8MB
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   | held mutexes= "mutator lock"(shared held)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   native: #00 pc 00006c19  /system/lib64/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned long, ucontext*)+57)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   native: #01 pc 0038aa60  /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+96)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   native: #02 pc 0035a627  /system/lib64/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+215)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   native: #03 pc 0010e1c3  /system/lib64/libart.so (art::JniAbort(char const*, char const*)+947)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   native: #04 pc 0010f13c  /system/lib64/libart.so (art::JniAbortF(char const*, char const*, ...)+220)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   native: #05 pc 0011015e  /system/lib64/libart.so (art::ScopedCheck::CheckVirtualMethod(_jobject*, _jmethodID*)+430)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   native: #06 pc 0011eeca  /system/lib64/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, __va_list_tag*)+106)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   native: #07 pc 000aad35  /system/lib64/libandroid_runtime.so (_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+133)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   native: #08 pc 0145267a  /data/dalvik-cache/x86_64/system@framework@boot.oat (Java_android_animation_PropertyValuesHolder_nCallFloatMethod__Ljava_lang_Object_2JF+226)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.animation.PropertyValuesHolder.nCallFloatMethod(Native method)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1296)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:952)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1207)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1248)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:659)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:682)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.view.Choreographer.doCallbacks(Choreographer.java:580)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.view.Choreographer.doFrame(Choreographer.java:549)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
02-09 11:37:14.426 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.os.Handler.handleCallback(Handler.java:739)
02-09 11:37:14.427 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.os.Handler.dispatchMessage(Handler.java:95)
02-09 11:37:14.427 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.os.Looper.loop(Looper.java:135)
02-09 11:37:14.427 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at android.app.ActivityThread.main(ActivityThread.java:5221)
02-09 11:37:14.427 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke!(Native method)
02-09 11:37:14.427 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke(Method.java:372)
02-09 11:37:14.427 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
02-09 11:37:14.427 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
02-09 11:37:14.427 3739-3739/com.twitter.android A/art: art/runtime/check_jni.cc:65]

#3

Ive tested it in a Android 5.0 emulator and also in a Samsung Galaxy Alpha Android version 5.0.2.
Does the crash happens to you only when you have the Twitter App installed and working fine when is not?


Android 5.0 : Twitter Login always failed if I have Twitter app on the device
#4

Yes, only with the Twitter app installed. Seems to be crashing in all apps that use the sign in including Periscope.


#5

I have the same issue with Android 5. (works for 6, 7 and 4). It used to work before. It only occurs if Twitter app is installed. My stacktrace:

Authorization completed with an error
com.twitter.sdk.android.core.TwitterAuthException: Authorize failed.
at com.twitter.sdk.android.core.identity.AuthHandler.handleOnActivityResult(AuthHandler.java:98)
at com.twitter.sdk.android.core.identity.TwitterAuthClient.onActivityResult(TwitterAuthClient.java:161)
at com.my.app.ui.LoginActivity.onActivityResult(LoginActivity.java:179)
at android.app.Activity.dispatchActivityResult(Activity.java:6179)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3638)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3685)
at android.app.ActivityThread.access$1300(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)


#6

This was not happen before I update Twitter App (Sorry, I forgot to check previous version)
I think this is issue of Twitter App itself.

Additional Info:

  • I found following message in logcat

E/Vold: Failed to find mounted volume for /storage/sdcard1/Android/data/com.twitter.android/cache/

  • responseCode is Activity.RESULT_CANCELED

#8

Hi all, this should be fixed in version 6.35 of Twitter for Android released 2/17


#9

Yes, this is finally working!


#10