I started playing with tweetinvi to connect to twitter api. I keep getting "The remote server returned an error: (401) Unauthorized." error message when I call CredentialsCreator.GetCredentialsFromVerifierCode() after being redirected.
I'm kinda of lost on what to do next.
This is the only code that I use:
protected void Page_Load( object sender, EventArgs e )
{
Tweetinvi.WebLogic.TemporaryCredentials applicationCredentials = (Tweetinvi.WebLogic.TemporaryCredentials)CredentialsCreator.GenerateApplicationCredentials( Properties.Settings.Default.TwitterConsumerKey, Properties.Settings.Default.TwitterConsumerSecret );
if (Request["oauth_token"] == null)
{
string url = CredentialsCreator.GetAuthorizationURLForCallback( applicationCredentials, "http://127.0.0.1:53260/twitter.aspx" );
Response.Redirect( url, false );
}
else
{
string verifierCode = Request["oauth_verifier"];
// error calling this code
var newCredentials = CredentialsCreator.GetCredentialsFromVerifierCode( verifierCode, applicationCredentials );
Console.WriteLine( "Access Token = {0}", newCredentials.AccessToken );
Console.WriteLine( "Access Token Secret = {0}", newCredentials.AccessTokenSecret );
}
}
Looks like you have everything correct. It might be the library you are using. Have you tried LinqToTwitter?
They have several examples you can test at http://linqtotwitter.codeplex.com/SourceControl/latest#ReadMe.txt. Just download their source files and you'll find Linq2TwitterDemos_WebForms project that you can text out.