public NegotiationToken GetToken() { WebRequest request = WebRequest.Create(requestUri); request.Method = "POST"; Nonce nonce = Nonce.Generate(); TimeStamp timestamp = TimeStamp.Generate(); BaseString baseString = new BaseString(request.RequestUri, request.Method, nonce, timestamp, credentials, HmacSha1Signature.MethodName); Signature signature = new HmacSha1Signature(baseString.ToString(), credentials); AuthorizationHeader header = new AuthorizationHeader(credentials, nonce, timestamp, signature); request.Headers.Add(HttpRequestHeader.Authorization, header.ToString()); using (WebResponse res = request.GetResponse()) using (Stream s = res.GetResponseStream()) using (StreamReader sr = new StreamReader(s)) { NameValueCollection response = HttpUtility.ParseQueryString(sr.ReadToEnd()); return(new NegotiationToken(response["oauth_token"], response["oauth_token_secret"])); } }
public void SignRequest(WebRequest request) { Nonce nonce = Nonce.Generate(); TimeStamp timestamp = TimeStamp.Generate(); Signature signature = GenerateSignature(request, nonce, timestamp); AuthorizationHeader header = GenerateAuthorizationHeader(nonce, timestamp, signature); AddAuthorizationHeaderToRequest(request, header); }