public string GetSignedUrl() { var signature = GetSignature(); string url = _normalizedUrl + "?" + _normalizedParameters + "&oauth_signature=" + EncodingUtility.UrlEncode(signature); return(url); }
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); }
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)); }
public OAuthUrlProvider Callback(string callback) { _parameterMap.Set("oauth_callback", EncodingUtility.UrlEncode(callback)); return(this); }