Failed to get request token on devices running Android M

Failed to log in to Twitter on Android 6.0 preview devices. It works great on all other devices.

The code below is used to initialize the fabric using twitter.

The TWITTER_ KEY and TWITTER_SECRET keys were obtained from the Twitter app settings.
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); 

Here is the error log I received while logging in 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) 
+13
twitter twitter-fabric fabric-twitter
source share
9 answers

Here is what you need to do

Twitter dev account-> settings-> callBack url

and then if you do for android (means logging in for Android devices)

twittersdk: //
(add this to the callback)

if you are doing for iOS (e.g. for logging in to Apple devices)

twitterkit-CONSUMERKEY: //
(add this to the callback)

and click the update settings button, it will work :)

+18
source share

Before this solution, I tried a valid URL (even google.com ). But in my case, this did not work.

Then I found this solution that worked well for me:

Step 1. Go to your Twitter app’s settings by going to https://apps.twitter.com/ and selecting the “ Settings ” tab, then add twittersdk:// as the twittersdk:// URL of the callback. (I found this in the lib class.)

Step 2. Save the update.

Step 3: try your application again.

+15
source share

I have the same problem and solved. In my case, I need to set the callback url in twitter dev account.

Twitter dev account-> setting-> callBack url (set any valid URL, for example www.google.com)

+8
source share

this is the best solution when twitter auth does not work without an application. I tried with a valid firebase callback url but it didn’t work and I also looked for this problem a lot but didn’t get the exact solution, @Moinkhan solution worked for me and saved my time thanks to @Moinkhan it works

Prior to this solution, I tried using a valid URL and even google.com. But for my business, this did not work.

I found the solution below and it works well for me.

Step 1: go to your twitter settings https://apps.twitter.com/ >> Tab Settings >> Fill this “twittersdk: //” text in the callback url field (I found it in the lib class)

Step 2. Save the update.

Step 3: check your application again

+7
source share

I ran into the same problem (just a few minutes ago).

Go to Twitter Application Management
Click on the “application” you are currently working on →
Go to the Settings tab →
1) Callback URL : Enter any valid URL (e.g. your website’s homepage)
2) Enable callback blocking (it is recommended that you enable callback blocking so that applications cannot rewrite the callback URL) . Make sure it is not checked.

Twitter Kit tries to use webview if twitter application is not located.
Part of the Twitter dialing website is to redefine the callback URL .

The Callback Url field information clearly indicates: to prevent your application from using callbacks, leave this field blank.
So, we need to write any valid url :)

Link:
Personal experience gained moments ago: P
Failed to get request token.

+4
source share

Create your access token in the "Key and Access" tab

0
source share

I had the same issue on iOS, and found a hint here :
Apparently now I need to set the callback url

http://twitter-oauth.callback

Sind, I did this, the login is working again.

0
source share

After going through many solutions, one of them worked for me - just add twittersdk: // as another callback URL in the settings section of your Twitter application.

0
source share
  1. Make sure the callback URLs are entered.
  2. Make sure Twitter (Android, iOS) is installed on your device

Hope this helps. This works well for me ( https://www.assetstore.unity3d.com/en/#!/content/79450 ).

-one
source share

All Articles