使用 Twitter 登录突然停止工作 [英] Signin with Twitter stopped working suddenly
问题描述
我有一个 Web 应用程序,它使用 Twitter 的 OAUTH 登录用户.我使用的是 Twitter4J 版本 2.1.11
I have a web application which uses Twitter's OAUTH to login users. I am using Twitter4J version 2.1.11
此应用一直运行良好,但最近停止运行,可能是在过去几周内停止运行.
This application has been working flawlessly and stopped working very recently, possibly in the past couple of weeks.
public static void authWithTwitter() {
try {
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
RequestToken requestToken = twitter.getOAuthRequestToken(getTwitterCallbackUrl());
// save requestToken for retreival after user logs in
// code not shown for brevity
redirect(requestToken.getAuthenticationURL());
} catch(Exception e) {
cLogger.error("Could not perform pre twitter login steps", e);
}
}
此代码将(直到应用程序运行)将用户重定向到 Twitter 的登录页面,在成功验证后,该页面将调用回调 URL.
This code would (till the app was working) redirect the user to Twitter's login page, which upon successful authentication, would call the callback url.
但是,最近,这已停止工作,我收到以下异常.
However, recently, this has stopped working and I get the following Exception.
401:Authentication credentials (http://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid conumer key/secret, access token/secret, and the system clock in in sync.
Failed to validate oauth signature and token
Relevant discussions can be on the Internet at:
http://www.google.co.jp/search?q=8dda30a8 or
http://www.google.co.jp/search?q=68161d96
TwitterException{exceptionCode=[8dda30a8-68161d96], statusCode=401, retryAfter=0, rateLimitStatus=null, version=2.1.11}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:199)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:75)
at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:112)
at twitter4j.http.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:148)
at twitter4j.TwitterOAuthSupportBaseImpl.getOAuthRequestToken(TwitterOAuthSupportBaseImpl.java:88)
at twitter4j.Twitter.getOAuthRequestToken(Twitter.java:58)
我进行了一些搜索并确认我在 dev.Twitter.com 的应用设置中正确设置了回调网址
I did some searching and verified that I have the callback url set properly in my app's settings in dev.Twitter.com
我还没有重新生成密钥和消费者秘密,但如果我不能让它工作,那将是下一步.
I have not yet re-generated the key and consumer secret, but that would be the next step if I cannot get it to work.
有人知道为什么这会停止工作吗?
Does anyone have a clue, why this would stop working ?
推荐答案
确保服务器时钟设置正确.如果距离 Twitter 的请求超过几分钟,则请求将失败.
Make sure the servers clock is set correctly. If it is more than a few minutes off from Twitter's requests will fail.
这篇关于使用 Twitter 登录突然停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!