public static string GenerateAuthorizationHeader(Uri uri, String consumerKey, String consumerSecret, String token, String tokenSecret, String httpMethod) { OAuthUtil oauthUtil = new OAuthUtil(); string timeStamp = oauthUtil.GenerateTimeStamp(); string nonce = oauthUtil.GenerateNonce(); string signature = oauthUtil.GenerateSignature( uri, consumerKey, consumerSecret, token, tokenSecret, httpMethod.ToUpper(), timeStamp, nonce); StringBuilder sb = new StringBuilder(); sb.Append("OAuth oauth_version=\"1.0\","); sb.AppendFormat("oauth_nonce=\"{0}\",", EncodingPerRFC3986(nonce)); sb.AppendFormat("oauth_timestamp=\"{0}\",", EncodingPerRFC3986(timeStamp)); sb.AppendFormat("oauth_consumer_key=\"{0}\",", EncodingPerRFC3986(consumerKey)); if (!String.IsNullOrEmpty(token)) { sb.AppendFormat("oauth_token=\"{0}\",", EncodingPerRFC3986(token)); } sb.Append("oauth_signature_method=\"HMAC-SHA1\","); sb.AppendFormat("oauth_signature=\"{0}\"", EncodingPerRFC3986(signature)); return sb.ToString(); }
public static string GenerateAuthorizationHeader(Uri uri, String consumerKey, String consumerSecret, String token, String tokenSecret, String httpMethod) { OAuthUtil oauthUtil = new OAuthUtil(); string timeStamp = oauthUtil.GenerateTimeStamp(); string nonce = oauthUtil.GenerateNonce(); string signature = oauthUtil.GenerateSignature( uri, consumerKey, consumerSecret, token, tokenSecret, httpMethod.ToUpper(), timeStamp, nonce); StringBuilder sb = new StringBuilder(); sb.Append("OAuth oauth_version=\"1.0\","); sb.AppendFormat("oauth_nonce=\"{0}\",", EncodingPerRFC3986(nonce)); sb.AppendFormat("oauth_timestamp=\"{0}\",", EncodingPerRFC3986(timeStamp)); sb.AppendFormat("oauth_consumer_key=\"{0}\",", EncodingPerRFC3986(consumerKey)); if (!String.IsNullOrEmpty(token)) { sb.AppendFormat("oauth_token=\"{0}\",", EncodingPerRFC3986(token)); } sb.Append("oauth_signature_method=\"HMAC-SHA1\","); sb.AppendFormat("oauth_signature=\"{0}\"", EncodingPerRFC3986(signature)); return(sb.ToString()); }