示例#1
0
        public string GetSignedUrl()
        {
            var signature = GetSignature();

            string url = _normalizedUrl
                         + "?" + _normalizedParameters
                         + "&oauth_signature=" + EncodingUtility.UrlEncode(signature);

            return(url);
        }
示例#2
0
        private string GetSignatureBase()
        {
            var elements = _parameterMap
                           .Select(parameter => parameter.Key + '=' + parameter.Value)
                           .ToArray();

            _normalizedParameters = string.Join("&", elements);

            var signatureBase = _httpMethod
                                + '&' + EncodingUtility.UrlEncode(_normalizedUrl)
                                + '&' + EncodingUtility.UrlEncode(_normalizedParameters);

            return(signatureBase);
        }
示例#3
0
        private string GetSignature()
        {
            if (_parameterMap.Get("oauth_signature_method") != "HMAC-SHA1")
            {
                throw new ArgumentException("SignatureMethod HMAC-SHA1 is mandatory");
            }

            var tokenSecret = string.IsNullOrEmpty(_tokenSecret) ? "" : EncodingUtility.UrlEncode(_tokenSecret);
            var secret      = EncodingUtility.UrlEncode(_consumerSecret) + '&' + tokenSecret;
            var hmacsha1    = new HMACSHA1 {
                Key = Encoding.ASCII.GetBytes(secret)
            };

            var signatureBase = GetSignatureBase();

            return(ComputeHash(hmacsha1, signatureBase));
        }
示例#4
0
 public OAuthUrlProvider Callback(string callback)
 {
     _parameterMap.Set("oauth_callback", EncodingUtility.UrlEncode(callback));
     return(this);
 }