sainath sagar
sainath sagar

Reputation: 509

Twitter login code is not working

This is my code, I am trying to connect to twitter but it is not giving error. I am using Twitterizer2 dll in this project. Any help is greatly appreciated.

 public UserOauthTokens TwitterLogin(string ConsumerKey, string ConsumerSecret)
 {
        UserOauthTokens utk = new UserOauthTokens();

        try
        {
            if (HttpContext.Current.Request["oauth_token"] == null)
            {
                OAuthTokenResponse reqToken = OAuthUtility.GetRequestToken(ConsumerKey, ConsumerSecret, HttpContext.Current.Request.Url.AbsoluteUri);
                HttpContext.Current.Response.Redirect(string.Format("http://twitter.com/oauth/authorize?oauth_token={0}", reqToken.Token));
            }
            else
            {
                utk.Oauth_Token = HttpContext.Current.Request["oauth_token"].ToString();
                utk.Oauth_Verifier = HttpContext.Current.Request["oauth_verifier"].ToString();
            }

            return utk;
        }
        catch (Exception ex)
        {
            return utk;
        }
    }

Upvotes: 0

Views: 75

Answers (1)

Terence Eden
Terence Eden

Reputation: 14334

The documentation says that you must use https.

Try changing the line to https://twitter.com/oauth/authorize?oauth_token={0}

Note the extra s in there.

Also, make sure you're using the latest version of the library.

Upvotes: 0

Related Questions