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

New Post: 401 Not Authorized Exception when calling GetCredentialsFromVerifierCode

$
0
0
Hi Linvi,

Thanks for your patient help, picking up that AuthorisationSecret was the missing piece and now it works from end to end.

Keep up the great work on this lovely library.

All the best,
Russell

P.S. for anybody else following this, if it helps, here is the final working solution

public OAuthDetails GenerateAuthorisationRequest()
        {



            var applicationCredentials = CredentialsCreator.GenerateApplicationCredentials(oauth_consumer_key, oauth_consumer_secret);
            
            
            
            var url = CredentialsCreator.GetAuthorizationURL(applicationCredentials);
            
            /// Having made this call, you now have both the captcha URL, and the and the authorisation secret that is linked to this URL
            /// This secret is available from the previously created applicationCredentials

            
            var details = new OAuthDetails
                (
                    applicationCredentials.AuthorizationKey, 
                    "",
                    url
                );

            details.AuthorisationSecret = applicationCredentials.AuthorizationSecret;


            return details;


        }

        public OAuthDetails ConfirmAuthorisationRequest(string authorisationKey, string authorisationSecret, string authorisationPinCode)
        {



            var applicationCredentials =
                CredentialsCreator.GenerateApplicationCredentials(oauth_consumer_key, oauth_consumer_secret);

            //Now add the key and tmeporary authorisation secret that were generated from the previous call to GetAuthorizationURL
            applicationCredentials.AuthorizationKey    = authorisationKey;
            applicationCredentials.AuthorizationSecret = authorisationSecret;


            var result = CredentialsCreator.GetCredentialsFromVerifierCode(authorisationPinCode, applicationCredentials);
            //And now you should have the final secret that is needed to work with the API.

            return OAuthDetails.Build
                (
                    authorisationKey,
                    result.AccessTokenSecret,
                    true
                );
        }

Viewing all articles
Browse latest Browse all 4126

Trending Articles



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