I'm using Twitterizer library with my website project. In our website we are using the Login in with Twitter button. The problem we have that on some computers it keeps directing the user to Twitter and ask him to authenticate and allow the application to interact. How can I stop that if the user has already authenticated our application from before?
This is the code I'm using to the button:
string callbackUrl = string.Concat(Request.Url.GetLeftPart(UriPartial.Authority), "/Callback.aspx");
if (Request.UrlReferrer != null)
{
callbackUrl = string.Format("{0}?sendto={1}", callbackUrl, HttpUtility.UrlEncode(Request.UrlReferrer.AbsoluteUri));
}
OAuthTokenResponse requestTokenResponse = OAuthUtility.GetRequestToken(
ConfigurationManager.AppSettings["Twitter.ConsumerKey"],
ConfigurationManager.AppSettings["Twitter.ConsumerSecret"],
callbackUrl);
string authUrl = OAuthUtility.BuildAuthorizationUri(requestTokenResponse.Token,true).AbsoluteUri;
Response.Redirect(authUrl);
Solved it by changing the authUrl to the following:
string authUrl = "https://api.twitter.com/oauth/authenticate?oauth_token=" + requestTokenResponse.Token;