i am facing this error, right now in oauthusing linq to twitter library:
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<error>Required oauth_verifier parameter not provided</error>
<request>/oauth/access_token</request>
</hash>
i have followed this documentation link: https://linqtotwitter.codeplex.com/wikipage?title=Implementing%20OAuth%20for%20ASP.NET%20Web%20Forms&referringTitle=Learning%20to%20use%20OAuth to implement the OAuth process, I get the this error at following line: await auth.CompleteAuthorizeAsync(new Uri(twitterCallbackUrl));
below is the full code, please help me on this:
AspNetAuthorizer auth;
string twitterCallbackUrl = "http://127.0.0.1:58192/Default.aspx";
protected async void Page_Load(object sender, EventArgs e)
{
auth = new AspNetAuthorizer
{
CredentialStore = new SessionStateCredentialStore
{
ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"]
},
GoToTwitterAuthorization =
twitterUrl => Response.Redirect(twitterUrl, false)
};
if (!Page.IsPostBack && Request.QueryString["oauth_token"] != null)
{
__await auth.CompleteAuthorizeAsync(new Uri(twitterCallbackUrl));__
// This is how you access credentials after authorization.
// The oauthToken and oauthTokenSecret do not expire.
// You can use the userID to associate the credentials with the user.
// You can save credentials any way you want - database, isolated
// storage, etc. - it's up to you.
// You can retrieve and load all 4 credentials on subsequent queries
// to avoid the need to re-authorize.
// When you've loaded all 4 credentials, LINQ to Twitter will let you
// make queries without re-authorizing.
//
var credentials = auth.CredentialStore;
string oauthToken = credentials.OAuthToken;
string oauthTokenSecret = credentials.OAuthTokenSecret;
string screenName = credentials.ScreenName;
ulong userID = credentials.UserID;
//Response.Redirect("~/Default.aspx", false);
}
}
protected async void AuthorizeButton_Click(object sender, EventArgs e)
{
await auth.BeginAuthorizeAsync(new Uri(twitterCallbackUrl));
//await auth.BeginAuthorizeAsync(Request.Url);
}
The problem occurs because your custom URL doesn't include the parameters that Twitter returned after the application requested authorization. If you set a breakpoint on CompleteAuthorizationAsync and type Request.Url into the Immediate window, you'll see these parameters:
If you still want to manually specify your URL, you need to include these parameters. Here's one way to do that:
string completeOAuthUrl = twitterCallbackUrl + Request.Url.Query;
await auth.CompleteAuthorizeAsync(completeOAuthUrl);
Alternatively, you can just use the page URL because that will already contains the proper parameters:
await auth.CompleteAuthorizeAsync(Request.Url);