【问题标题】:The same OAuth token fetch fails with .NET Core 3.1 but works with full .NET Framework.NET Core 3.1 相同的 OAuth 令牌获取失败,但适用于完整的 .NET Framework
【发布时间】:2020-10-30 17:09:16
【问题描述】:

我正在将我们的代码从 .NET Framework 升级到 .NET Core 3.1,但在我们处理 Salesforce API 身份验证的服务中遇到了问题。

Salesforce 令牌端点返回错误

错误请求:{"error":"invalid_grant","error_description":"authentication failure"}

当我在 .NET Core 中运行我的代码时。当我使用完整的框架时,它工作得很好。

_tokenClient = factory.CreateClient("TokenClient");
_tokenClient.BaseAddress = new Uri(_options.TokenUrl);

HttpContent content = new FormUrlEncodedContent(new Dictionary<string, string>
{
      {"grant_type", "password"},
      {"client_id", _options.ClientId},
      {"client_secret", _options.ClientSecret},
      {"username", _options.Username},
      {"password", _options.Password},
});

var response = await _tokenClient.PostAsync("token", content);

【问题讨论】:

    标签: c# .net .net-core salesforce


    【解决方案1】:

    完整的 .NET Framework 处理 url 编码的方式与 net-core 不同。我的参数中包含导致此问题的&amp;amp;。将其更改为 &amp; 即可解决它...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-25
      • 2020-08-02
      • 2018-12-06
      • 1970-01-01
      • 2016-09-17
      • 2022-01-18
      相关资源
      最近更新 更多