Пример #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"));
        }
Пример #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"));
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public AuthorizeInfo GetAuthorizeInfo()
        {
            String nonce     = OAuthClient.GenerateNonce();
            String timestamp = OAuthClient.GenerateTimeStamp();
            String url       = this.RequestTokenUrl;

            SignatureInfo si = OAuthClient.GenerateSignature(new Uri(url), this.ConsumerKey, this.ConsumerSecret
                                                             , "", "", "GET", 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();
            //正規表現でoauth_token,oauth_token_secret取得
            AuthorizeInfo ai = new AuthorizeInfo();

            ai.AuthorizeUrl       = String.Format("{0}?{1}", this.AuthorizeUrl, result);
            ai.RequestToken       = this.GetMatchValue(RegexList.OAuthToken, result);
            ai.RequestTokenSecret = this.GetMatchValue(RegexList.OAuthTokenSecret, result);
            return(ai);
        }