private void AddAuthParameters(
            ICollection <WebParameter> parameters,
            string timestamp,
            string nonce)
        {
            WebParameterCollection parameterCollection = new WebParameterCollection()
            {
                new WebParameter("oauth_consumer_key", this.ConsumerKey),
                new WebParameter("oauth_nonce", nonce),
                new WebParameter("oauth_signature_method", OAuthRequest.ToRequestValue(this.SignatureMethod)),
                new WebParameter("oauth_timestamp", timestamp),
                new WebParameter("oauth_version", this.Version ?? "1.0")
            };

            if (!OAuthRequest.IsNullOrBlank(this.Token))
            {
                parameterCollection.Add(new WebParameter("oauth_token", this.Token));
            }
            if (!OAuthRequest.IsNullOrBlank(this.CallbackUrl))
            {
                parameterCollection.Add(new WebParameter("oauth_callback", this.CallbackUrl));
            }
            if (!OAuthRequest.IsNullOrBlank(this.Verifier))
            {
                parameterCollection.Add(new WebParameter("oauth_verifier", this.Verifier));
            }
            if (!OAuthRequest.IsNullOrBlank(this.SessionHandle))
            {
                parameterCollection.Add(new WebParameter("oauth_session_handle", this.SessionHandle));
            }
            foreach (WebParameter webParameter in parameterCollection)
            {
                parameters.Add(webParameter);
            }
        }
        private string GetClientSignatureAuthorizationQuery(WebParameterCollection parameters)
        {
            string newSignatureXauth = this.GetNewSignatureXAuth(parameters);

            parameters.Add("oauth_signature", newSignatureXauth);
            return(OAuthRequest.WriteAuthorizationQuery(parameters));
        }
        private string GetSignatureAuthorizationHeader(WebParameterCollection parameters)
        {
            string newSignature = this.GetNewSignature(parameters);

            parameters.Add("oauth_signature", newSignature);
            return(this.WriteAuthorizationHeader(parameters));
        }
Exemple #4
0
        private string GetClientSignatureAuthorizationQuery(WebParameterCollection parameters)
        {
            var signature = GetNewSignatureXAuth(parameters);

            parameters.Add("oauth_signature", signature);

            return(WriteAuthorizationQuery(parameters));
        }
Exemple #5
0
        private string GetSignatureAuthorizationHeader(WebParameterCollection parameters)
        {
            var signature = GetNewSignature(parameters);

            parameters.Add("oauth_signature", signature);

            return(WriteAuthorizationHeader(parameters));
        }
        private void AddAuthParameters(ICollection <WebParameter> parameters, string timestamp, string nonce)
        {
            var authParameters = new WebParameterCollection
            {
                new WebParameter("oauth_consumer_key", ConsumerKey),
                new WebParameter("oauth_nonce", nonce),
                new WebParameter("oauth_signature_method", ToRequestValue(SignatureMethod)),
                new WebParameter("oauth_timestamp", timestamp),
                new WebParameter("oauth_version", Version ?? "1.0")
            };

            if (Type == OAuthRequestType.ProtectedResource)
            {
                if (Token != null)
                {
                    authParameters.Add(new WebParameter("oauth_token", Token));
                }
            }
            else
            {
                if (!IsNullOrBlank(Token))
                {
                    authParameters.Add(new WebParameter("oauth_token", Token));
                }
            }

            if (!IsNullOrBlank(CallbackUrl))
            {
                authParameters.Add(new WebParameter("oauth_callback", CallbackUrl));
            }

            if (!IsNullOrBlank(Verifier))
            {
                authParameters.Add(new WebParameter("oauth_verifier", Verifier));
            }

            if (!IsNullOrBlank(SessionHandle))
            {
                authParameters.Add(new WebParameter("oauth_session_handle", SessionHandle));
            }

            foreach (var authParameter in authParameters)
            {
                parameters.Add(authParameter);
            }
        }