【发布时间】:2016-08-22 16:46:41
【问题描述】:
我正在创建一个程序来使用 Twitter4j API 搜索具有给定关键字的推文,但在身份验证期间出现错误:
Exception in thread "main" 401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.
message - Invalid or expired token.
code - 89
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=506c3b98 or
http://www.google.co.jp/search?q=1136695b
TwitterException{exceptionCode=[506c3b98-1136695b], statusCode=401, message=Invalid or expired token., code=89, retryAfter=-1, rateLimitStatus=null, version=4.0.4}
我验证了我的 twitter4j.properties 文件中的所有令牌,并尝试了 SO 站点中提到的所有可能的解决方案,但它们对我不起作用。我花了几个小时来纠正错误,但仍然不知道是什么问题?
【问题讨论】:
-
你能发布你的认证过程的代码吗?
-
我没有使用 ConfigurationBuilder 代码进行身份验证,我只制作了 twitter4j.properties 文件,您将使用 twitter4j 库进行身份验证。
-
你在 twitter4j.properties 文件中存储了什么?据我所知,您需要拥有 consumerKey 和 consumerSecret,然后使用它您可以请求 OAuthRequestToken。看起来你使用了错误的令牌。
-
我正在使用 oauth.consumerKey, oauth.consumerSecret, oauth.accessToken, oauth.accessTokenSecret 。我多次验证了所有这些。我应该在 Twitter 应用程序的回调 URL 中放置什么?
标签: java authentication twitter twitter4j