开发者

twitterizer OAuthUtility GetAccessToken what are requestToken and verifier?

I'm trying to integrate a client's开发者_StackOverflow中文版 web-site w/ Twitter using twitterizer. I mistakenly started off using an old version of the library and then updated to the new version (2.3.2) and a lot changed.

My first problem is that GetAccessToken takes more parameters now but I can't find any documentation for these parameters: requestToken and Verifier. Can somebody please point me in the right direction?

Here is the code I'm trying to make work:

    string ConsumerKey = System.Configuration.ConfigurationManager.AppSettings["ConsumerKey"];
    string ConsumerSecret = System.Configuration.ConfigurationManager.AppSettings["ConsumerSecret"];
    OAuthTokenResponse responseToken = OAuthUtility.GetAccessToken(ConsumerKey, ConsumerSecret,);
    //Cache the UserId

    System.Web.HttpContext.Current.Session["GetCachedUserId"] = responseToken.UserId;
    OAuthTokens accessToken = new OAuthTokens();
    accessToken.AccessToken = responseToken.Token;
    accessToken.AccessTokenSecret = responseToken.TokenSecret;
    accessToken.ConsumerKey = ConsumerKey;
    accessToken.ConsumerSecret = ConsumerSecret;
    System.Web.HttpContext.Current.Session["TwitterAccessToken"] = responseToken.Token;
    System.Web.HttpContext.Current.Session["TwitterAccessTokenSecret"] = responseToken.TokenSecret;
    System.Web.HttpContext.Current.Session["AccessToken"] = accessToken;

TIA


Sorry I don't know how twitterizer works as I'd never used an OAuth library. But written one... Hope this can help you on understanding what requestToken and Verifier is:

Twitter's developer site has a simple tutorial on what needs to be send and received for authorization using OAuth. You might want to check on that first for how the process works http://dev.twitter.com/pages/auth

"Access token" is the second part of OAuth, verifier token comes before this request. Here is the process as simple as it can be:

Get an one time working oauth_token from Twitter (https://api.twitter.com/oauth/request_token)

Use the incoming token for building an url, letting user to accept/deny application. (https://api.twitter.com/oauth/access_token?oauth_token=the_incoming_token)

Twitter gives us two new tokens, one ouath_token and oauth_verifier. With these two, we ask twitter for application authorization. (https://api.twitter.com/oauth/authorize)

If successful twitter gives back two new tokens, oauth_token and oauth_token_secret. These two needs to be saved or stored, as they will be used on every request we make to twitter.


This should work, just use a null or empty string for the verifier parameter.

OAuthTokenResponse tokens = OAuthUtility.GetAccessToken(
    "ConsumerKey",
    "ConsumerSecret",
    Request.QueryString["oauth_token"],
    "");

I couldn't find much documentation on it either, the best I found was: http://www.twitterizer.net/documentation/html/M_Twitterizer_OAuthUtility_GetAccessToken.htm

and all it says is the verifier is "The pin number or verifier string." My guess is that it may be used for desktop applications that use a pin number to verify.


This should work, just use a null or empty string for the verifier parameter. Try this,

OAuthTokenResponse accessTokenResponse = OAuthUtility.GetAccessToken(consumerKey, consumerSecret, Request.QueryString["oauth_token"], Request.QueryString["oauth_verifier"]);

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜