I am using Linq2Twitter in my application (MVC5) to connect to twitter. After authorizing I am getting null values for OAuthTokenSecret, ScreenName and 0 for UserID. I am not able to tweet since I am not having OAuthTokenSecret.
I am using below code...
//To authorize
var auth = new MvcAuthorizer
{
CredentialStore = new SessionStateCredentialStore
{
ConsumerKey = ConfigurationManager.AppSettings["twitterKey"],
ConsumerSecret = ConfigurationManager.AppSettings["twitterSecret"]//,
//OAuthToken = null,
//OAuthTokenSecret=null
}
};
return await auth.BeginAuthorizationAsync(redirectUri);
//To complete authorization
var auth = new MvcAuthorizer
{
CredentialStore = new SessionStateCredentialStore()
};
auth.CompleteAuthorizeAsync(uri);
return auth;
PS: Authentication code is in Services Layer.
You should await the call to CompleteAuthorizeAync:
await auth.CompleteAuthorizeAsync(uri);
The method is returning before the operation completes, meaning that you're examining state that isn't yet available.