开发者

Getting error 401 trying to connect to Twitter with play.libs.OAuth

I am using Play Framework and play.libs.OAuth, trying to connect to Twitter using the following code:

public static void twitterConnect()
{
    Response response;
    ServiceInfo twitterServiceInfo = new ServiceInfo(
        "https://api.twitter.com/oauth/request_token",
        "https://api.twitter.com/oauth/access_token",
        "https://api.twitter.com/oauth/authorize",
        "ZA*****************Dw",
        "Zy*************************************U4");

    if(OAuth.isVerifierResponse()) {
        // ...
    } else {
        OAuth twitter = OAuth.service(twitterServiceInfo);
        response = twitter.retrieveRequestToken(); <-- NOT WORKING!!!
        redirect(twitter.redirectUrl(response.token));
    }
}

but at the line marked <-- NOT WORKING开发者_运维技巧!!!; I am getting the following error:

OAuth.Error: NOT_AUTHORIZED - Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.

I've double checked my consumer keys and secrets, as well as the request, access and authorize URLs, but to no avail.

Any ideas as to what is wrong with my code?


I ripped out the OAuth code, and reimplemented using the Scribe library written by Fernandez Pablo. Seems I'm getting further now. :)


Apply a new twitter oauth key and secret with Callback URL may solve the problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜