/// <returns>An access token</returns> public async static Task<ICredential> ObtainAccessTokenAsync( this HttpClient httpClient, Uri requestUri, HttpMethod httpMethod, ICredential consumerCredentials, ICredential authorizationToken, RequestToken requestToken) { var httpRequest = new HttpRequestMessage(httpMethod, requestUri); var parameters = new Dictionary<string, string>(); string oauthHeader = parameters.GenerateOAuthHeader( httpMethod.Method, consumerCredentials.Key, consumerCredentials.Secret, requestUri, token: authorizationToken.Key, tokenSecret: requestToken.Secret, verifier: authorizationToken.Secret); httpRequest.Headers.Authorization = new AuthenticationHeaderValue("OAuth", oauthHeader); HttpResponseMessage response = await httpClient.SendAsync(httpRequest); string responseString = await response.Content.ReadAsStringAsync(); return ParseAccessToken(responseString); }
public async static Task<HttpResponseMessage> AccessResourceAsync( this HttpClient httpClient, Uri resourceUri, HttpMethod httpMethod, ICredential consumerCredentials, ICredential accessToken, Dictionary<string, string> parameters) { var httpRequest = new HttpRequestMessage(httpMethod, resourceUri); string oauthHeader = parameters.GenerateOAuthHeader( httpMethod: httpMethod.Method, consumerKey: consumerCredentials.Key, consumerSecret: consumerCredentials.Secret, requestUrl: resourceUri, token: accessToken.Key, tokenSecret: accessToken.Secret); httpRequest.Headers.Authorization = new AuthenticationHeaderValue("OAuth", oauthHeader); return await httpClient.SendAsync(httpRequest); }