几个月前,我在自己的Android应用中集成了Firebase + Twitter OAuth。 最近,我在重构该应用程序,并注意到经过较早测试的Firebase + Twitter身份验证无法在我的所有设备和不同帐户上正常工作。 从那时起,我一直在尝试多种解决方法,例如:
我没有任何理由在此处列出任何与auth相关的代码,因为它与一般示例和代码段非常相似,例如 https://firebase.google.com/docs/auth/android/twitter-login?authuser=0和 https://github.com/twitter/twitter-kit-android/wiki/Getting-Started和https://github.com/twitter/twitter-kit-android/wiki/Log-In-with-Twitter。 而且,当然,所有这些都在Twitter + Firebase身份验证工作时经过了测试。
我得到的异常取决于初始化Twitter SDK的方式。
例如,当我像这样在Application的onCreate()
中初始化Twitter时:
Twitter.initialize(this)
我知道
com.google.firebase.FirebaseException: An internal error has occurred.
[ Failed to get successful verify_credentials response:{"errors":[{"code":32,"message":"Could not authenticate you."}]} ]
at com.google.firebase.auth.api.internal.zzds.zzb(Unknown Source)
at com.google.firebase.auth.api.internal.zzew.zza(Unknown Source)
at com.google.firebase.auth.api.internal.zzeo.zzc(Unknown Source)
at com.google.firebase.auth.api.internal.zzep.onFailure(Unknown Source)
at com.google.firebase.auth.api.internal.zzdy.dispatchTransaction(Unknown Source)
at com.google.android.gms.internal.firebase_auth.zzb.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:453)
此外,当我像这样在Application的onCreate()
中初始化Twitter时:
val config = TwitterConfig.Builder(this)
.logger(DefaultLogger(Log.DEBUG))
.twitterAuthConfig(TwitterAuthConfig("CONSUMER_KEY", "CONSUMER_SECRET"))
.debug(true)
.build()
Twitter.initialize(config)
我知道
E/Twitter: 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:143)
at com.twitter.sdk.android.core.identity.TwitterLoginButton.onActivityResult(TwitterLoginButton.java:131)
at com.kkaun.mediator.ui.user.login.providers.TwitterSignInActivity.onActivityResult(TwitterSignInActivity.kt:90)
at android.app.Activity.dispatchActivityResult(Activity.java:6572)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3710)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3757)
at android.app.ActivityThread.-wrap16(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5452)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:762)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
W/TwitterSignInActivity: twitterLogin:failure
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:143)
at com.twitter.sdk.android.core.identity.TwitterLoginButton.onActivityResult(TwitterLoginButton.java:131)
at com.kkaun.mediator.ui.user.login.providers.TwitterSignInActivity.onActivityResult(TwitterSignInActivity.kt:90)
at android.app.Activity.dispatchActivityResult(Activity.java:6572)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3710)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3757)
at android.app.ActivityThread.-wrap16(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5452)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:762)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
众所周知,Twitter在2018年10月31日停止了对Twitter Kit的支持,如此处https://blog.twitter.com/developer/en_us/topics/tools/2018/discontinuing-support-for-twitter-kit-sdk.html所述。 所以我想知道,这可能是我遇到问题的原因吗?