Failed to get request token


#1

I use the Twitter API 1.8.0 (com.twitter.sdk.android:twitter:1.8.0) in android application that was installed on the LG Electronics LGV32,
As a result of calling the Twitter#logIn(), it was de exception of the following.
Solution or would not know?

09-25 16:30:09.491 29572-29572/club.foru E/Twitter﹕ Invalid json: <?xml version="1.0" encoding="UTF-8"?>

Desktop applications only support the oauth_callback value ‘oob’
/oauth/request_token

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 8 path $
at com.google.gson.JsonParser.parse(JsonParser.java:65)
at com.google.gson.JsonParser.parse(JsonParser.java:45)
at com.twitter.sdk.android.core.TwitterApiException.parseApiError(TwitterApiException.java:136)
at com.twitter.sdk.android.core.TwitterApiException.readApiError(TwitterApiException.java:125)
at com.twitter.sdk.android.core.TwitterApiException.(TwitterApiException.java:58)
at com.twitter.sdk.android.core.TwitterApiException.convert(TwitterApiException.java:110)
at com.twitter.sdk.android.core.Callback.failure(Callback.java:45)
at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5430)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 8 path $
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1572)
at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1421)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:544)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:427)
at com.google.gson.JsonParser.parse(JsonParser.java:60)
at com.google.gson.JsonParser.parse(JsonParser.java:45)
at com.twitter.sdk.android.core.TwitterApiException.parseApiError(TwitterApiException.java:136)
at com.twitter.sdk.android.core.TwitterApiException.readApiError(TwitterApiException.java:125)
at com.twitter.sdk.android.core.TwitterApiException.(TwitterApiException.java:58)
at com.twitter.sdk.android.core.TwitterApiException.convert(TwitterApiException.java:110)
at com.twitter.sdk.android.core.Callback.failure(Callback.java:45)
at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5430)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
09-25 16:30:09.491 29572-29572/club.foru E/Twitter﹕ Failed to get request token
com.twitter.sdk.android.core.TwitterApiException: 401 Authorization Required
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:383)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:818)
09-25 16:30:09.521 29572-29572/club.foru E/Twitter﹕ Authorization completed with an error
com.twitter.sdk.android.core.TwitterAuthException: Failed to get request token
at com.twitter.sdk.android.core.identity.OAuthController$1.failure(OAuthController.java:95)
at com.twitter.sdk.android.core.internal.oauth.OAuth1aService$1.failure(OAuth1aService.java:215)
at com.twitter.sdk.android.core.Callback.failure(Callback.java:45)
at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5430)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)


#2

I also have similar problem.

In my case, Twitter Kit shows below error, when the Twitter App is not installed and the kit tries to use webview.
If the twitter app is installed, everything is fine

kit version is 1.8.0.

Invalid json: <?xml version="1.0" encoding="UTF-8"?>
 <hash>
   <error>Desktop applications only support the oauth_callback value 'oob'</error>
   <request>/oauth/request_token</request>
 </hash>
 Failed to get request token
 com.twitter.sdk.android.core.TwitterApiException: 401 Authorization Required
     at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:383)
     at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
     at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
     at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
     at retrofit.Platform$Android$2$1.run(Platform.java:142)
     at java.lang.Thread.run(Thread.java:818)
 Authorization completed with an error
 com.twitter.sdk.android.core.TwitterAuthException: Failed to get request token
     at com.twitter.sdk.android.core.identity.OAuthController$1.failure(OAuthController.java:95)
     at com.twitter.sdk.android.core.internal.oauth.OAuth1aService$1.failure(OAuth1aService.java:215)
     at com.twitter.sdk.android.core.Callback.failure(Callback.java:45)
     at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
     at android.os.Handler.handleCallback(Handler.java:739)
     at android.os.Handler.dispatchMessage(Handler.java:95)
     at android.os.Looper.loop(Looper.java:148)
     at android.app.ActivityThread.main(ActivityThread.java:5417)
     at java.lang.reflect.Method.invoke(Native Method)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 Failed to get request token
 com.twitter.sdk.android.core.TwitterAuthException: Failed to get request token
     at com.twitter.sdk.android.core.identity.OAuthController$1.failure(OAuthController.java:95)
     at com.twitter.sdk.android.core.internal.oauth.OAuth1aService$1.failure(OAuth1aService.java:215)
     at com.twitter.sdk.android.core.Callback.failure(Callback.java:45)
     at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
     at android.os.Handler.handleCallback(Handler.java:739)
     at android.os.Handler.dispatchMessage(Handler.java:95)
     at android.os.Looper.loop(Looper.java:148)
     at android.app.ActivityThread.main(ActivityThread.java:5417)
     at java.lang.reflect.Method.invoke(Native Method)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

oh, I’m using LoginButton, and the device is Nexus 5 running Android 6.0


#3

この問題ですが、
http://d.hatena.ne.jp/speg03/20091019/1255957580
こちらにあるように、twitter app の設定を変更すると改善されます。


#4

Thanks, setting callback url solved the problem!


#7
  1. select your app
  2. click Settings tab
  3. enter some url in Callback URL (any valid url is ok, since the Twitter Kit will override it)

voila!


#10

In case you create twitter api key from fabric plugin, you can edit callback url from fabric’s web dashboard


#11

thx!
This issue has been resolved.


#12