Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to get request token on Android M running Devices

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)
like image 465
Arunkumar MG Avatar asked Oct 20 '15 04:10

Arunkumar MG


2 Answers

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 :)

like image 173
vallabh Avatar answered Oct 14 '22 16:10

vallabh


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

I then found this solution, which worked well for me:

Step 1: Go to your twitter app's settings by logging in at https://apps.twitter.com/ and selecting the Settings tab, then add twittersdk:// as a callback url. (I found it in lib class.)

Step 2: Save your update.

Step 3: Try your app again.

like image 39
Moinkhan Avatar answered Oct 14 '22 15:10

Moinkhan