Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="authorizeInfo"></param>
 /// <param name="oauthVerifier"></param>
 public void Authenticate(OAuth1AuthorizeInfo authorizeInfo, String oauthVerifier)
 {
     this.AccessToken = this.GetAccessToken(authorizeInfo, oauthVerifier);
     if (this.AccessToken.State == OAuthAccessTokenState.Error)
     {
         throw new OAuthAuthenticateException(this.AccessToken.RawValue, "Failure to get AccessToken by OAuth1.0.");
     }
 }
Exemplo n.º 2
0
 public static OAuth1AuthorizeInfo Create(String authorizeUrl, String text)
 {
     OAuth1AuthorizeInfo ai = new OAuth1AuthorizeInfo();
     ai.AuthorizeUrl = String.Format("{0}?{1}", authorizeUrl, text);
     ai.RequestToken = GetMatchValue(RegexList.OAuthToken, text);
     ai.RequestTokenSecret = GetMatchValue(RegexList.OAuthTokenSecret, text);
     return ai;
 }
Exemplo n.º 3
0
        public static OAuth1AuthorizeInfo Create(String authorizeUrl, String text)
        {
            OAuth1AuthorizeInfo ai = new OAuth1AuthorizeInfo();

            ai.AuthorizeUrl       = String.Format("{0}?{1}", authorizeUrl, text);
            ai.RequestToken       = GetMatchValue(RegexList.OAuthToken, text);
            ai.RequestTokenSecret = GetMatchValue(RegexList.OAuthTokenSecret, text);
            return(ai);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public OAuth1AuthorizeInfo GetAuthorizeInfo()
        {
            String             url      = this.RequestTokenUrl;
            var                cm       = new GetRequestTokenCommand(this.ConsumerKey, this.ConsumerSecret, "", "", HttpMethodName.Post);
            SignatureInfo      si       = OAuth1Client.GenerateSignature(new Uri(url), cm, OAuthSignatureTypes.HMACSHA1);
            HttpRequestCommand command  = this.CreateHttpRequestCommand(HttpMethodName.Post, url, "", "");
            String             bodyText = this.GetBodyText(command);

            //正規表現でoauth_token,oauth_token_secret取得
            return(OAuth1AuthorizeInfo.Create(this.AuthorizeUrl, bodyText));
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="authorizeInfo"></param>
        /// <param name="oauthVerifier"></param>
        /// <returns></returns>
        public OAuth1AccessToken GetAccessToken(OAuth1AuthorizeInfo authorizeInfo, String oauthVerifier)
        {
            var ai = authorizeInfo;
            var cm = new GetRequestTokenCommand(this.ConsumerKey, this.ConsumerSecret
                                                , ai.RequestToken, ai.RequestTokenSecret, HttpMethodName.Post);
            var si = OAuth1Client.GenerateSignature(new Uri(this.AccessTokenUrl), cm, OAuthSignatureTypes.HMACSHA1);
            HttpRequestCommand command = new HttpRequestCommand(String.Format("{0}?{1}&oauth_verifier={2}&oauth_signature={3}"
                                                                              , this.AccessTokenUrl, si.NormalizedRequestParameters, oauthVerifier, si.Signature), HttpMethodName.Post);
            var res = this.GetResponse(command);

            return(OAuth1AccessToken.Create(res.BodyText));
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public OAuth1AuthorizeInfo GetAuthorizeInfo()
        {
            String             url     = this.RequestTokenUrl;
            var                cm      = new GetRequestTokenCommand(this.ConsumerKey, this.ConsumerSecret, "", "", HttpMethodName.Post);
            SignatureInfo      si      = OAuth1Client.GenerateSignature(new Uri(url), cm, OAuthSignatureTypes.HMACSHA1);
            HttpRequestCommand command =
                new HttpRequestCommand(String.Format("{0}?{1}&oauth_signature={2}", url, si.NormalizedRequestParameters, si.Signature), HttpMethodName.Post);
            String bodyText = this.GetBodyText(command);

            //正規表現でoauth_token,oauth_token_secret取得
            return(OAuth1AuthorizeInfo.Create(this.AuthorizeUrl, bodyText));
        }