private string WriteAuthorizationHeader(WebParameterCollection parameters) { var sb = new StringBuilder("OAuth "); if (!IsNullOrBlank(Realm)) { sb.AppendFormat("realm=\"{0}\",", OAuthTools.UrlEncodeRelaxed(Realm)); } parameters.Sort((l, r) => l.Name.CompareTo(r.Name)); foreach (var parameter in parameters.Where(parameter => !IsNullOrBlank(parameter.Name) && !IsNullOrBlank(parameter.Value) && (parameter.Name.StartsWith("oauth_") || parameter.Name.StartsWith("x_auth_")))) { sb.AppendFormat("{0}=\"{1}\",", parameter.Name, parameter.Value); } sb.Remove(sb.Length - 1, 1); var authorization = sb.ToString(); return(authorization); }
private string GetNewSignatureXAuth(WebParameterCollection parameters) { var timestamp = OAuthTools.GetTimestamp(); var nonce = OAuthTools.GetNonce(); AddXAuthParameters(parameters, timestamp, nonce); var signatureBase = OAuthTools.ConcatenateRequestElements(Method.ToUpperInvariant(), RequestUrl, parameters); var signature = OAuthTools.GetSignature(SignatureMethod, SignatureTreatment, signatureBase, ConsumerSecret, TokenSecret); return(signature); }