Twitter 401 身份验证错误(Thread.sleep() 是否与我的时钟不同步)
在发布这个问题之前我已经考虑了很多。我有几个关于 Twitter 和 Twitter4j API 的问题。我正在从 Twitter 收集用户的关注者。它运行良好一段时间,然后显示
401:Authentication credentials ( http://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid conumer key cret, access token cret, and the system clock in in sync.
error - Timestamp out of bounds
request - /1/account erify_credentials.json?include_entities=false
Relevant discussions can be on the Internet at:
http://www.google.co.jp/search?q=6f0f59ca or
http://www.google.co.jp/search?q=3f8a87d4
TwitterException{exceptionCode=[6f0f59ca-3f8a87d4], statusCode=401, retryAfter=0, rateLimitStatus=null, version=2.2.0}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:189)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:93)
at twitter4j.TwitterBaseImpl.fillInIDAndScreenName(TwitterBaseImpl.java:131)
at twitter4j.TwitterImpl.verifyCredentials(TwitterImpl.java:1150)
at com.xinlab.blueapple.twitterrobot.ConvertRobot$1.run(ConvertRobot.java:77)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Failed to get mentions: 401:Authentication credentials ( http://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid conumer key cret, access token cret, and the system clock in in sync.
error - Timestamp out of bounds
request - /1/account erify_credentials.json?include_entities=false
我在网上查看过但没有得到正确答案的错误。有些人建议同步你的时钟,但没有人提到如何同步(我不知道这是否是问题,可能还有其他问题)。
凭证不会有错,因为它可以在 15-20 分钟内正常工作。我还想告诉您,我也在使用 Thread.sleep(x),因为 Twitter 不允许每小时请求超过 350 个查询。
因此,如果问题出在时间同步上,正如大多数用户在其他帖子中所说的那样,那么这与 Thread.sleep(12000)
更新有关:我发现我得到的点error 是 Twitter 向推文受保护的用户请求关注者的时间。是不是跟它有关系?
I have given a lot of thought before posting this questions. I have several issues regarding Twitter
and Twitter4j
API. I am collecting followers of users from Twitter. It runs well for some time and then show the error
401:Authentication credentials ( http://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid conumer key cret, access token cret, and the system clock in in sync.
error - Timestamp out of bounds
request - /1/account erify_credentials.json?include_entities=false
Relevant discussions can be on the Internet at:
http://www.google.co.jp/search?q=6f0f59ca or
http://www.google.co.jp/search?q=3f8a87d4
TwitterException{exceptionCode=[6f0f59ca-3f8a87d4], statusCode=401, retryAfter=0, rateLimitStatus=null, version=2.2.0}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:189)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:93)
at twitter4j.TwitterBaseImpl.fillInIDAndScreenName(TwitterBaseImpl.java:131)
at twitter4j.TwitterImpl.verifyCredentials(TwitterImpl.java:1150)
at com.xinlab.blueapple.twitterrobot.ConvertRobot$1.run(ConvertRobot.java:77)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Failed to get mentions: 401:Authentication credentials ( http://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid conumer key cret, access token cret, and the system clock in in sync.
error - Timestamp out of bounds
request - /1/account erify_credentials.json?include_entities=false
I have looked on the web but didn't get the right answer. Some guys suggested to sync your clock but nobody mentioned how to sync(I don't know this is the problem or not, there might be some other problem).
Credential can not be wrong as it works fine for 15-20 min. I also would like to tell that I am also using Thread.sleep(x)
as Twitter doesn't allow to request more than 350 queries per hour.
So if the problem is in time synchronization as most of the users said in other posts then is that something to do with Thread.sleep(12000)
Update: I figured out that the point at which I am getting error is the time when Twitter asks for followers from a user whose tweet is protected. Is is something to do with it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
建议同步时钟是因为请求有一个时间戳,用于在生成用于验证请求的签名时为哈希算法提供种子。
签名特定于所发出的请求、发出请求的人、发出请求的应用程序、发出时间以及另一个随机值。
请求对时间敏感,因此服务 (Twitter) 将检查时间戳是否在 +/- 时间内。确切的时间尚不清楚,但服务应该使其尽可能小。
您应该使用互联网时间服务同步您的系统时钟。这是 Google 为我提供的一篇关于在 linux 中设置时间的文章: http://www.go2linux.org/how-to-set-the-date-and-time-in-linux
The suggestion to sync your clock is because the request has a timestamp that is used to seed the hash algorithm when it generates a signature used to validate the request.
The signature is specific to the request being made, the person making it, the application making it, when it was made, and another random value.
Requests are time sensitive, so the service (Twitter) will check that the timestamp falls within a +/- time. The exact time is unknown, but the service should make it as small as is feasible.
You should sync your system clock using an internet time service. Here is an article that Google provided me on setting the time in linux: http://www.go2linux.org/how-to-set-the-date-and-time-in-linux
是的,建议是检查/同步您的时钟。我尝试做同样的事情,并不断更新我的系统时间(笔记本电脑/PC)。 1 小时后,我注意到我的模拟器的系统时间与服务器不同步。我停止了模拟器并再次启动它有效。您还可以手动更改系统时间:
希望这对某人有帮助。
谢谢你!
Yes the suggestion is to check/sync your clock. I tried to do same and I kept on updating my system time(Laptop/PC). After 1Hour I came to notice that my emulator's system time was not on sync with the server. I stopped emulator and started again It worked. Also you can manually change the system time from:
Hope this helps someone.
Thank You!