我正在使用针对Android应用程序的结构Twitter身份验证,并且只有在我没有twitter应用程序的手机中安装了twitter官方应用程序时它才有效我在尝试进行身份验证时遇到此异常。 是否必须在手机上安装Twitter应用程序才能通过Twitter进行身份验证?
06-09 19:00:41.574 12893-13421/client.tclient.com.client E/SharedPreferencesImpl: Couldn't create directory for SharedPreferences file /data/user/0/client.tclient.com.client/shared_prefs/com.crashlytics.prefs.xml
06-09 19:00:43.574 12893-12893/client.tclient.com.client E/ApkAssets: Error while loading asset assets/natives_blob_64.bin: java.io.FileNotFoundException: assets/natives_blob_64.bin
06-09 19:00:43.575 12893-12893/client.tclient.com.client E/ApkAssets: Error while loading asset assets/snapshot_blob_64.bin: java.io.FileNotFoundException: assets/snapshot_blob_64.bin
06-09 19:00:44.342 12893-12893/client.tclient.com.client E/Twitter: 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>
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.<init>(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: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)
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.<init>(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: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)
06-09 19:00:44.343 12893-12893/client.tclient.com.client 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: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)
06-09 19:00:44.383 12893-12893/client.tclient.com.client 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:213)
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)
答案 0 :(得分:0)
您正在尝试将XML解析为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>
Desktop applications only support the oauth_callback value 'oob'
还提供有关您的实施的更多信息。