我正在使用此方法,我恢复了错误“远程主机已强制中断现有连接”
public static async void GetAccessToken()
{
var client = new HttpClient();
// Create the HttpContent for the form to be posted.
var requestContent = new FormUrlEncodedContent(
new[] {
new KeyValuePair<string, string>("client_secret","xxxxx"),
new KeyValuePair<string, string>("client_id","xxxxx"),
new KeyValuePair<string, string>("grant_type","authorization_code"),
new KeyValuePair<string, string>("redirect_uri","http://localhost"),
new KeyValuePair<string, string>("code","xxxxx")
});
// Get the response.
HttpResponseMessage response = await client.PostAsync(
"https://domain-uber.com/oauth/v2/token",
requestContent);
// Get the response content.
HttpContent responseContent = response.Content;
// Get the stream of the content.
using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
{
var result = await reader.ReadToEndAsync();
}
}