Twitter4j 401身份验证

时间:2011-09-21 14:43:01

标签: java android

这是导致问题的代码。以下是Logcat。我打印了例外。我多次检查了消费者和密钥。任何人都可以放弃光明或如何获得有关此问题的更多细节吗?

我还应该提一下,我已经在模拟器和真实手机上运行了这个脚本,两者都带回了相同的logcat

09-21 15:27:25.504: ERROR/HelloWorld(17680): 401:Authentication credentials (https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set valid conumer key/secret, access token/secret, and the system clock in in sync.
09-21 15:27:25.504: ERROR/HelloWorld(17680): Failed to validate oauth signature and token
09-21 15:27:25.504: ERROR/HelloWorld(17680): Relevant discussions can be on the Internet at:
09-21 15:27:25.504: ERROR/HelloWorld(17680):     http://www.google.co.jp/search?q=10f5ada3 or
09-21 15:27:25.504: ERROR/HelloWorld(17680):     http://www.google.co.jp/search?q=dceba039
09-21 15:27:25.504: ERROR/HelloWorld(17680): TwitterException{exceptionCode=[10f5ada3-dceba039], statusCode=401, retryAfter=-1, rateLimitStatus=null, featureSpecificRateLimitStatus=null, version=2.2.4}
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:185)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:102)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:121)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:104)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:276)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at com.blundell.tut.ttt.TweetToTwitterActivity.loginNewUser(TweetToTwitterActivity.java:109)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at com.blundell.tut.ttt.TweetToTwitterActivity.buttonLogin(TweetToTwitterActivity.java:83)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at java.lang.reflect.Method.invokeNative(Native Method)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at java.lang.reflect.Method.invoke(Method.java:521)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at android.view.View$1.onClick(View.java:2077)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at android.view.View.performClick(View.java:2461)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at android.view.View$PerformClick.run(View.java:8890)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at android.os.Handler.handleCallback(Handler.java:587)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at android.os.Looper.loop(Looper.java:123)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at java.lang.reflect.Method.invokeNative(Native Method)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at java.lang.reflect.Method.invoke(Method.java:521)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
09-21 15:27:25.504: ERROR/HelloWorld(17680):     at dalvik.system.NativeStart.main(Native Method)

4 个答案:

答案 0 :(得分:3)

也许,你已经创建了一个桌面应用程序。在浏览器应用上更改您应用的类型。 这是一个很好的教程http://www.androidhive.info/2012/09/android-twitter-oauth-connect-tutorial/

答案 1 :(得分:2)

09-21 15:27:25.504: ERROR/HelloWorld(17680): 401:Authentication credentials (https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret

您在Twitter中创建的应用程序中输入了错误的消费者密钥密钥

确保您提供了两个密钥,同时确保它是正确的。

进一步参考检查此Integrating Twitter with Android

答案 2 :(得分:0)

查看我的应用设置应用类型

访问:

  • 只读
  • 读写
  • 读取,写入和访问直接消息

您的应用需要什么类型的访问权限?注意:@Anywhere应用程序需要 read&写访问。

详细了解我们的应用程序权限模型

默认为只读,请再次选择读写。

答案 3 :(得分:0)

我的设备的日期不正确。看起来很奇怪,但确实有效。当日期设置正确时,它工作正常。您可以显示警告,要求用户检查设备的当前日期和/或时间。