public string GenerateSignatureBase() { if (Token == null) { Token = string.Empty; } if (string.IsNullOrEmpty(ConsumerKey)) { throw Error.MissingRequiredOAuthParameter(this, Parameters.OAuth_Consumer_Key); } if (string.IsNullOrEmpty(SignatureMethod)) { throw Error.MissingRequiredOAuthParameter(this, Parameters.OAuth_Signature_Method); } if (string.IsNullOrEmpty(RequestMethod)) { throw Error.RequestMethodHasNotBeenAssigned("RequestMethod"); } var allParameters = new List <QueryParameter>(); if (FormEncodedParameters != null && RequestMethod == "POST") { allParameters.AddRange(FormEncodedParameters.ToQueryParameters()); } if (QueryParameters != null) { allParameters.AddRange(QueryParameters.ToQueryParameters()); } if (Cookies != null) { allParameters.AddRange(Cookies.ToQueryParameters()); } if (AuthorizationHeaderParameters != null) { allParameters.AddRange(AuthorizationHeaderParameters.ToQueryParameters().Where(q => q.Key != Parameters.Realm)); } // remove the signature parameter and the token parameter if it's not specified if (string.IsNullOrEmpty(Token)) { allParameters.RemoveAll(param => param.Key == Parameters.OAuth_Token); } allParameters.RemoveAll(param => param.Key == Parameters.OAuth_Signature); //allParameters.RemoveAll(param => param.Key == Parameters.OAuth_Token && string.IsNullOrEmpty(param.Value)); // build the uri return(UriUtility.FormatParameters(RequestMethod, new Uri(NormalizedRequestUrl), allParameters)); }
public string GenerateSignatureBase() { if (Token == null) { Token = string.Empty; } if (string.IsNullOrEmpty(ConsumerKey)) { throw Error.MissingRequiredOAuthParameter("ConsumerKey"); } if (string.IsNullOrEmpty(SignatureMethod)) { throw Error.MissingRequiredOAuthParameter("SignatureMethod"); } if (string.IsNullOrEmpty(RequestMethod)) { throw Error.RequestMethodHasNotBeenAssigned("RequestMethod"); } var allParameters = new List <QueryParameter>(); if (FormEncodedParameters != null) { allParameters.AddRange(FormEncodedParameters.ToQueryParameters()); } if (QueryParameters != null) { allParameters.AddRange(QueryParameters.ToQueryParameters()); } if (Cookies != null) { allParameters.AddRange(Cookies.ToQueryParameters()); } if (AuthorizationHeaderParameters != null) { allParameters.AddRange( AuthorizationHeaderParameters.ToQueryParameters().Where(q => q.Name != Parameters.Realm)); } // remove the signature parameter allParameters.RemoveAll(param => param.Name == Parameters.OAuth_Signature); // build the uri return(UriUtility.FormatParameters(RequestMethod, new Uri(NormalizedRequestUrl), allParameters)); }