开发者

Problem in Oauth with twitter4j

This is what I'm getting while calling twitter.getOauthRequestToken(callbackUrl). I've added the correct consumer key and consumer secret.

    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.
<?xml version="1.0" encoding="UTF-8"?>
<hash>
  <error>Desktop applications only support the oauth_callback value 'oob'</error>
  <request>/oauth/request_token</request>
</hash>

I debugged the code multiple times and found every credentials in place before above call is made. Anyone who has used twitter4j or not can please indicate the problem? Or should I use another oauth library? Any suggestions?


i have same problem, but when i fill the field of callback URL my apps run normally. maybe you should fill the field of Callback URL.


I guess you registered your app as a "desktop" app. Go to twitter applications and either delete the app and create a new one or edit the existing one with "web" as the app type.


Try this:

Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer("yourConsumerKey","yourConsumerSecret");
RequestToken requestToken = twitter.getOAuthRequestToken();

session.setAttribute("token", requestToken.getToken());
session.setAttribute("tokenSecret", requestToken.getTokenSecret());

// REDIRECT USER TO TWITTER LOGIN PAGE

response.sendRedirect(requestToken.getAuthorizationURL());

CALLBACK URL PAGE CODE:

Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer("yourConsumerKey","yourConsumerSecret");

AccessToken aToken = twitter.getOAuthAccessToken(new RequestToken((String) session.getAttribute("token"), (String) session.getAttribute("tokenSecret")));
                twitter.setOAuthAccessToken(aToken);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜