Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

New Post: Generate Credential Examples

$
0
0
Hello Everyone,

I have a workaround to this problem, I am using tweetinvi into my project and also stuck into into this problem as well.

First of all sorry for my english.

1.Using Below code to redirect user to twitter:-

var applicationCredentials = CredentialsCreator.GenerateApplicationCredentials(ConsumerKey, ConsumerSecret);
var url = CredentialsCreator.GetAuthorizationURLForCallback(applicationCredentials, HttpContext.Current.Request.Url.AbsoluteUri);
//Saving applicationCredentials into session for using them later.
Session["authkey"] = applicationCredentials.AuthorizationKey;
Session["authSecret"] = applicationCredentials.AuthorizationSecret;
Response.Redirect(url);
  1. Using Below code for getting newcredentials on page load:-
        if (Request.QueryString["oauth_verifier"] != null)
        {
            var callbackURL = HttpContext.Current.Request.Url.AbsoluteUri;
            var applicationCredentials = CredentialsCreator.GenerateApplicationCredentials(ConsumerKey, ConsumerSecret);
            //Setting applicationCredentials to the previous one i saved in sessions.
            applicationCredentials.AuthorizationKey = Session["authkey"].ToString();
            applicationCredentials.AuthorizationSecret = Session["authSecret"].ToString();
            // Here we provide the entire URL where the user has been redirected
            var newCredentials = CredentialsCreator.GetCredentialsFromVerifierCode(Request.QueryString["oauth_verifier"].ToString(), applicationCredentials);
            if (newCredentials != null)
            {
                //use your credentials here newCredentials.AccessToken, newCredentials.AccessTokenSecret
            }
        }
    
Thanks,
Arvind

Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>