Salesforce Marketing Cloud API不会返回访问/授权令牌



我有一个应用程序,该应用程序请求营销云,以便在后续请求中使用以访问API的访问令牌。这是去年设计的,直到上周正常工作。自02/22以来,相同的请求一直在失败。这是请求令牌的示例代码:

public static async Task<string> GetAuthorizationToken(string ClientId, string ClientSecret)
    {
        string strAuthorizationToken = string.Empty;
        HttpClient client = new HttpClient();
        var dictParams = new Dictionary<string, string>()
        {
            { "clientId", ClientId }, {"clientSecret", ClientSecret }
        };
        var content = new FormUrlEncodedContent(dictParams);
        var response = await client.PostAsync("https://auth.exacttargetapis.com/v1/requestToken", content);
        if (response.IsSuccessStatusCode)
        {
            var strresponse = await response.Content.ReadAsStringAsync();
            //dynamic objResult = JsonConvert.DeserializeObject<dynamic>(strresponse);
            //strAuthorizationToken = objResult.accessToken;
        }
        return strAuthorizationToken;
    }
GetAuthorizationToken("*********", "*******").GetAwaiter().GetResult();

这是我从API遇到的错误:

{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  X-Mashery-Responder: 02-26
  Vary: Origin
  X-Mashery-Message-ID: f4cec199-2e7e-49e2-88e0-6673ffe849ed
  strict-transport-security: max-age=15552000; preload
  Content-Security-Policy: upgrade-insecure-requests
  x-xss-protection: 1; mode=block
  x-frame-options: DENY
  x-content-type-options: nosniff
  Referrer-Policy: strict-origin-when-cross-origin
  Connection: close
  Cache-Control: no-store, must-revalidate, no-cache, max-age=0, private
  Date: Tue, 26 Feb 2019 16:42:29 GMT
  Server: Apache
  Content-Length: 223
  Content-Type: application/json; charset=UTF-8
}}

我需要知道已更改的内容或在此代码中需要修复的内容,才能再次访问API。请帮助我如何再次使这项工作。预先感谢。

我正在发布答案,因为它已解决,并且可能对发送HTTP请求的其他人有帮助。

我必须添加以下代码行以指定要使用的安全协议:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls;

相关内容

  • 没有找到相关文章

最新更新