Failed to get request token on Android M running Devices
Asked Answered
G

9

19

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)
Giffard answered 20/10, 2015 at 4:49 Comment(1)
somethimes in developer console r u authenticate wia email is these confirm from your side ?? and check both virtual and real device...!!!Optimize
M
31

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.

Morphine answered 18/6, 2018 at 10:49 Comment(6)
Please don't keep posting the same answer in multiple old questions. Flag as duplicate if you think they are.#30511845Surplusage
The intention was to allow user to get answer even if the user visit this post.Morphine
@Shree and the question are different but solution are same for current scenario. But in future it can be a differentMorphine
@Morphine Thank youSiqueiros
@Morphine thks youSharecropper
Thanks @MorphineBerkeleian
C
29

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

Coorg answered 23/8, 2018 at 9:44 Comment(0)
E
9

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)

Everick answered 20/1, 2017 at 5:40 Comment(2)
I have already did it.Igot below error: com.twitter.sdk.android.core.TwitterAuthException: Failed to get request token The reason for this error is i dont have twitter app installed.If i do then it works fine What should i have to do?Toggle
@Toggle Same Problem here and that to SDK.M Devices only........... please anybody help..........Vale
B
7

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

Basket answered 7/8, 2018 at 9:38 Comment(1)
You saved my day. I wonder this is not working without the "twittersdk://"? Are you using Firebase UI?Nones
P
4

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

Persephone answered 2/11, 2017 at 16:10 Comment(0)
B
1

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.

Brockie answered 5/12, 2018 at 0:46 Comment(0)
S
0

Create your Your Access Token in Key and Access Token tab

Siddra answered 9/5, 2016 at 7:3 Comment(0)
C
0

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.

Certification answered 27/8, 2018 at 12:27 Comment(0)
C
-1
  1. Make sure your Callback Urls is inputted.
  2. 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).

Catty answered 5/7, 2018 at 15:53 Comment(1)
Twitter mustn't be installed on the device, it will open web view insteadInfarction

© 2022 - 2024 — McMap. All rights reserved.