Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="authorizeInfo"></param>
        /// <param name="oauthVerifier"></param>
        /// <returns></returns>
        public AccessTokenInfo GetAccessToken(AuthorizeInfo authorizeInfo, String oauthVerifier)
        {
            AuthorizeInfo ai = authorizeInfo;
            SignatureInfo si = OAuthClient.GenerateSignature(new Uri(this.AccessTokenUrl), this.ConsumerKey, this.ConsumerSecret
                                                             , ai.RequestToken, ai.RequestTokenSecret, "POST", OAuthClient.GenerateTimeStamp(), OAuthClient.GenerateNonce()
                                                             , OAuthClient.SignatureTypes.HMACSHA1);
            HttpClient cl = new HttpClient(String.Format("{0}?{1}&oauth_verifier={2}&oauth_signature={3}", this.AccessTokenUrl
                                                         , si.NormalizedRequestParameters, oauthVerifier, si.Signature));
            String s = cl.GetBodyText();

            return(AccessTokenInfo.Create(s, "oauth_token", "oauth_token_secret"));
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="requestToken"></param>
        /// <param name="requestTokenSecret"></param>
        /// <returns></returns>
        public AccessTokenInfo GetAccessToken(String requestToken, String requestTokenSecret)
        {
            String nonce     = OAuthClient.GenerateNonce();
            String timestamp = OAuthClient.GenerateTimeStamp();
            String url       = this.AccessTokenUrl;

            SignatureInfo si = OAuthClient.GenerateSignature(new Uri(url), this.ConsumerKey, this.ConsumerSecret
                                                             , requestToken, requestTokenSecret, "POST", timestamp, nonce, OAuthClient.SignatureTypes.HMACSHA1);
            HttpClient cl = new HttpClient(String.Format("{0}?{1}&oauth_signature={2}"
                                                         , url, si.NormalizedRequestParameters, si.Signature));
            String result = cl.GetBodyText();

            return(AccessTokenInfo.Create(result, "oauth_token", "oauth_token_secret"));
        }