示例#1
0
        private string GenerateSignature(HttpWebRequest request, FormParameters formParameters)
        {
            FormParameters parameters = FormParameters.OAuthDecode(request.RequestUri.Query);

            foreach (var item in _protocolParameters)
            {
                parameters.Add(item);
            }
            if (request.ContentType == "application/x-www-form-urlencoded")
            {
                foreach (var item in formParameters)
                {
                    parameters.Add(item);
                }
            }
            parameters.Sort();

            string signature = GenerateBaseSignature(request.Method, request.RequestUri, parameters);
            string secret    = EncodeSecret();

            Trace.WriteLine("Secret: " + secret);
            Trace.WriteLine("Signature: " + signature);

            return(Sign(secret, signature));
        }
示例#2
0
        private void SetTempToken()
        {
            FormParameters form = new FormParameters();

            if (TempTokenRequesting != null)
            {
                TempTokenRequesting(this, new OAuthRequestTokenEventArgs(form));
            }
            //_protocolParameters.Set("oauth_callback", CallbackUrl);
            form.Add("oauth_callback", CallbackUrl);

            // TODO: check TempTokenMethod

            HttpWebResponse response = AuthorizedPOST(TemporaryCredentialsUri, form);

            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                string         text  = sr.ReadToEnd();
                FormParameters reply = FormParameters.OAuthDecode(text);
                AuthorizedToken       = reply["oauth_token"];
                AuthorizedTokenSecret = reply["oauth_token_secret"];

                // TODO pass additional parameters to impl
            }
        }
示例#3
0
        public void Verify(string verifier)
        {
            _protocolParameters.Set("oauth_verifier", verifier);

            // TODO: check AccessTokenMethod

            HttpWebResponse response = AuthorizedPOST(AccessTokenUri);

            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                var            text  = sr.ReadToEnd();
                FormParameters reply = FormParameters.OAuthDecode(text);
                AuthorizedToken       = reply["oauth_token"];
                AuthorizedTokenSecret = reply["oauth_token_secret"];

                // TODO pass additional parameters to impl
            }
        }