I'm using Twitterizer. I got my Consumer key and Secret, and told Twitter my callback URL. However, after the user clicks permit, he gets a PIN to manually copy back to my application. I'm not even sure what I (the developer) am supposed to do with the PIN. Since the user isn't redirected back to the callback page, I'm not sure when that comes into play either.
I'm using the project template from 4 guys from Rolla. The callback page is internet visible (i.e. not just running on localhost)
开发者_如何学Pythonprotected string GetTwitterAuthorizationUrl()
{
string ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"];
string ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"];
OAuthTokenResponse reqToken = OAuthUtility.GetRequestToken(ConsumerKey, ConsumerSecret, "oob");
return "https://twitter.com/oauth/authorize?oauth_token=" + reqToken.Token;
}
Here is the corrected code:
string CallbackUrl2 = ConfigurationManager.AppSettings["CallbackUrl"];
OAuthTokenResponse reqToken = OAuthUtility.GetRequestToken(ConsumerKey, ConsumerSecret, CallbackUrl2);
return "https://twitter.com/oauth/authorize?oauth_token=" + reqToken.Token;
The reason the users are getting the PIN is because you have "oob" (out of browser) in your getrequesttoken call. Otherwise, they'd get a standard twitter authorization page asking if they want to authorize.
精彩评论