public AuthorizeHeader GetUserInfoAuthorizationHeader(string url, string realm, string consumerKey, string consumerSecret, string token, string tokenSecret, SignatureMethod signatureMethod = SignatureMethod.HMACSHA1, string httpMethod = "POST")
        {
            System.Diagnostics.Debug.WriteLine("");
            System.Diagnostics.Debug.WriteLine(token);
            System.Diagnostics.Debug.WriteLine(tokenSecret);
            System.Diagnostics.Debug.WriteLine("----");
            var timestamp = GenerateTimeStamp();
            var nounce    = GenerateNonce(timestamp);

            var protocolParameters = ExtractQueryStrings(url);

            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.ConsumerKey.GetStringValue(), consumerKey));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.SignatureMethod.GetStringValue(), signatureMethod.GetStringValue()));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Timestamp.GetStringValue(), timestamp));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Nounce.GetStringValue(), nounce));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Version.GetStringValue(), OAuthVersion));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Token.GetStringValue(), token));

            string signatureBaseString = GenerateSignatureBaseString(url, httpMethod, protocolParameters);

            System.Diagnostics.Debug.WriteLine(signatureBaseString);


            OAuthBase oauth = new OAuthBase();
            string    normUrl;
            string    requestParams;
            string    sigBase = oauth.GenerateSignatureBase(new Uri(url), consumerKey, token, tokenSecret, "GET", timestamp, nounce,
                                                            signatureMethod.GetStringValue(), out normUrl, out requestParams);
            string sig = oauth.GenerateSignature(new Uri(url), consumerKey, consumerSecret, token, tokenSecret, "GET", timestamp, nounce,
                                                 out normUrl, out requestParams);

            var signature = GenerateSignature(consumerSecret, signatureMethod, signatureBaseString, tokenSecret);

            return(new AuthorizeHeader(realm, consumerKey, signatureMethod.GetStringValue(), signature, timestamp, nounce, OAuthVersion, token, null));
        }
Esempio n. 2
0
        public AuthorizeHeader GetRequestTokenAuthorizationHeader(string url, string realm, string consumerKey, string consumerSecret, string callbackUrl, SignatureMethod signatureMethod = SignatureMethod.HMACSHA1, string httpMethod = "POST")
        {
            var urlEncodedCallback = UrlEncode(callbackUrl);
            var timestamp          = GenerateTimeStamp();
            var nounce             = GenerateNonce(timestamp);

            var protocolParameters = ExtractQueryStrings(url);

            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.ConsumerKey.GetStringValue(), consumerKey));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.SignatureMethod.GetStringValue(), signatureMethod.GetStringValue()));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Timestamp.GetStringValue(), timestamp));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Nounce.GetStringValue(), nounce));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Version.GetStringValue(), OAuthVersion));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Callback.GetStringValue(), callbackUrl));

            string signatureBaseString = GenerateSignatureBaseString(url, httpMethod, protocolParameters);
            var    signature           = GenerateSignature(consumerSecret, signatureMethod, signatureBaseString);

            return(new AuthorizeHeader(realm, consumerKey, signatureMethod.GetStringValue(), signature, timestamp, nounce, OAuthVersion, callbackUrl));
        }
Esempio n. 3
0
        public AuthorizeHeader GetAccessTokenAuthorizationHeader(string url, string realm, string consumerKey, string consumerSecret, string token, string verifier, string tokenSecret, SignatureMethod signatureMethod = SignatureMethod.HMACSHA1, string httpMethod = "POST")
        {
            var timestamp = GenerateTimeStamp();
            var nounce    = GenerateNonce(timestamp);

            var protocolParameters = ExtractQueryStrings(url);

            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.ConsumerKey.GetStringValue(), consumerKey));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.SignatureMethod.GetStringValue(), signatureMethod.GetStringValue()));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Timestamp.GetStringValue(), timestamp));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Nounce.GetStringValue(), nounce));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Version.GetStringValue(), OAuthVersion));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Token.GetStringValue(), token));
            protocolParameters.Add(new ProtocolParameter(OAuthProtocolParameter.Verifier.GetStringValue(), verifier));

            string signatureBaseString = GenerateSignatureBaseString(url, httpMethod, protocolParameters);

            System.Diagnostics.Debug.WriteLine(signatureBaseString);

            var signature = GenerateSignature(consumerSecret, signatureMethod, signatureBaseString, tokenSecret);

            return(new AuthorizeHeader(realm, consumerKey, signatureMethod.GetStringValue(), signature, timestamp, nounce, OAuthVersion, token, verifier));
        }