Not Response获取ASP NET C#中的访问令牌oauth 2.0 API UBER

时间:2018-08-02 14:22:16

标签: c# asp.net-mvc uber-api

我正在使用此方法,我恢复了错误“远程主机已强制中断现有连接”

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();
      }
    }

0 个答案:

没有答案