Twitter4J : Invalid / expired Token
since two days I am getting this exception : 12:30:52,220 WARN
(http-localhost/127.0.0.1:8080-11) 401:Authentication credentials were
missing or incorrect. Ensure that you have set valid consumer key/secret,
access token/secret, and the system clock is in sync.
<hash>
<error>Invalid / expired Token</error>
<request>/oauth/access_token</request>
</hash>
Relevant discussions can be found on the Internet at:
TwitterException{exceptionCode=[9ddbeb3a-767c89fe], statusCode=401,
message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.3}
Here is what I checked so far
1) My system time is ok 2) My consumer key / consumer secret are ok. 3) I
am using the official code snippets from the twitter4J page :
Twitter twitter = TwitterFactory.getSingleton();
String appId = ...
String appSecret = ...
twitter.setOAuthConsumer(appId, appSecret);
String redirectUrl = ...
RequestToken requestToken = twitter.getOAuthRequestToken(redirectUrl);
String authenticationURL = requestToken.getAuthenticationURL();
getSession().setAttribute(Constants.TWITTER, twitter);
getSession().setAttribute(Constants.REQUEST_TOKEN, requestToken);
redirect(authenticationURL);
And after the request comes back I am using the following :
String oauthVerifierTwitter = getParameter(Constants.OAUTH_VERIFIER);
if (oauthVerifierTwitter != null) {
Twitter twitter = getSession.getAttribute(Constants.TWITTER);
RequestToken token = (RequestToken)
getSession().getAttribute(Constants.REQUEST_TOKEN);
AccessToken oAuthAccessToken = twitter.getOAuthAccessToken(token,
oauthVerifierTwitter);
=> Exception
Any suggestions, anyone ?
No comments:
Post a Comment