【问题标题】:The server returned an invalid or incomplete HTTP response服务器返回无效或不完整的 HTTP 响应
【发布时间】:2021-09-11 15:20:26
【问题描述】:

我在 .Net 中对我的应用进行 OAuth 2 身份验证时遇到问题。我正在创建 BigCommerce 和 SmartPablo 之间的集成。通过 OAuth2 授权码授予单击应用程序授权和身份验证。

我的部分代码:

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://login.bigcommerce.com/oauth2/token");
Dictionary<string, string> body = new Dictionary<string, string>()
{
    {"client_id", "clientId"},
    {"client_secret", "clientSecret"},
    {"redirect_uri", baseUrl + "/auth/install"},
    {"grant_type", "authorization_code"},
    {"code", query["code"]},
    {"scope", query["scope"]},
    {"context", query["context"]}
};

request.Content = new FormUrlEncodedContent(body);
HttpResponseMessage response = await _clientFactory.CreateClient().SendAsync(request);

有人可以帮帮我吗?

【问题讨论】:

    标签: c# .net oauth-2.0 integration bigcommerce


    【解决方案1】:

    我强烈建议您使用 Postman 等实用程序来测试您的 API 端点。

    在不知道 API 工作所需的数据架构的情况下,发现问题可能会很复杂。

    同样在使用 PostMan 测试 API 之后,如果 C# 代码有问题,而 PostMan 成功,您应该嗅探请求以找到问题并修复它们

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多