可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Twitter login failed in Android 6.0 preview devices. Its working fine on all other devices.
Below code is used to initialize fabric with twitter.
TWITTER_ KEY and TWITTER_SECRET keys were obtained from twitter app settings.
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
Here is the error log i got during login using TwitterApiClient.
08-31 07:52:09.988 4692-4692/? E/Twitter: Failed to get request token
08-31 07:52:09.988 4692-4692/? E/Twitter: com.twitter.sdk.android.core.TwitterApiException: 401 Authorization Required
08-31 07:52:09.988 4692-4692/? E/Twitter: at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:383)
08-31 07:52:09.988 4692-4692/? E/Twitter: at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
08-31 07:52:09.988 4692-4692/? E/Twitter: at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
08-31 07:52:09.988 4692-4692/? E/Twitter: at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
08-31 07:52:09.988 4692-4692/? E/Twitter: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
08-31 07:52:09.988 4692-4692/? E/Twitter: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
08-31 07:52:09.988 4692-4692/? E/Twitter: at retrofit.Platform$Android$2$1.run(Platform.java:142)
08-31 07:52:09.988 4692-4692/? E/Twitter: at java.lang.Thread.run(Thread.java:818)
08-31 07:52:10.000 4692-4692/? E/Twitter: Authorization completed with an error
08-31 07:52:10.000 4692-4692/? E/Twitter: com.twitter.sdk.android.core.TwitterAuthException: Failed to get request token
08-31 07:52:10.000 4692-4692/? E/Twitter: at com.twitter.sdk.android.core.identity.OAuthController$1.failure(OAuthController.java:95)
08-31 07:52:10.000 4692-4692/? E/Twitter: at com.twitter.sdk.android.core.internal.oauth.OAuth1aService$1.failure(OAuth1aService.java:215)
08-31 07:52:10.000 4692-4692/? E/Twitter: at com.twitter.sdk.android.core.Callback.failure(Callback.java:45)
08-31 07:52:10.000 4692-4692/? E/Twitter: at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
08-31 07:52:10.000 4692-4692/? E/Twitter: at android.os.Handler.handleCallback(Handler.java:739)
08-31 07:52:10.000 4692-4692/? E/Twitter: at android.os.Handler.dispatchMessage(Handler.java:95)
08-31 07:52:10.000 4692-4692/? E/Twitter: at android.os.Looper.loop(Looper.java:148)
08-31 07:52:10.000 4692-4692/? E/Twitter: at android.app.ActivityThread.main(ActivityThread.java:5417)
08-31 07:52:10.000 4692-4692/? E/Twitter: at java.lang.reflect.Method.invoke(Native Method)
08-31 07:52:10.000 4692-4692/? E/Twitter: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-31 07:52:10.000 4692-4692/? E/Twitter: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
回答1:
Here are the things you need to do
Twitter dev account->setting->callBack url
and then if you are doing for the android (means login using for android devices )
twittersdk://
(add this in callback)
if you are doing for the iOS (means login using for apple devices )
twitterkit-CONSUMERKEY://
(add this in callback)
and hit update settings button
it will work :)
回答2:
Before this solution i tried valid url and even google.com too. But for my case it was not working.
i found below solution and it work well for me.
Step 1: go to your twitter app setting https://apps.twitter.com/ >> Tab settings >> Fill this text "twittersdk://" to your callback url field( i found it in lib class)
Step 2: Save your update
Step 3: check out your app again
回答3:
I have same problem and solved. In my case i need to set callback url in twitter dev account.
Twitter dev account->setting->callBack url(set any valid url like
www.google.com)
回答4:
this is the best solution when twitter auth not working without app. i tried with valid firebase auth callback url but not working and i also search this problem a lot but not getting the exact solution, @Moinkhan solution worked for me and save my time, thanks to @Moinkhan, it works
Before this solution i tried valid url and even google.com too. But for my case it was not working.
i found below solution and it work well for me.
Step 1: go to your twitter app setting https://apps.twitter.com/ >> Tab settings >> Fill this text "twittersdk://" to your callback url field( i found it in lib class)
Step 2: Save your update
Step 3: check out your app again
回答5:
I was facing the same issue(just moments back).
Go to Twitter Application Management ->
Click on the 'app' on which you are currently working ->
Click on 'Settings' tab ->
1) Callback URL: Insert any valid url(like homepage of your website)
2) Enable Callback Locking (It is recommended to enable callback locking to ensure apps cannot overwrite the callback url): Verify that it is unchecked
Twitter Kit tries to use a webview if the twitter app is not found.
The webview part of Twitter kit needs to override the callback url.
Info about Callback Url field clearly states: To restrict your application from using callbacks, leave this field blank.
So, we need to write down any valid url :)
Reference:
Personal experience obtained moments back :P
Failed to get request token
回答6:
Create your Your Access Token in Key and Access Token tab
回答7:
I had the same problem on iOS, and found a hint here:
Apparently, it is now required to set the Callback URL to
http://twitter-oauth.callback
Sind I did so, the login works again.
回答8:
After going through a lot of solutions, one that worked for me is
just add - twittersdk:// as one more callback URL in the setting section of your twitter app.
回答9:
- Make sure your Callback Urls is inputted.
- Make sure Twitter app is installed on your device(Android, iOS)
Hope this help. It work well for me (https://www.assetstore.unity3d.com/en/#!/content/79450).