salesforce-marketing-cloud - 无法为 Salesforce Marketing Cloud 令牌交换“代码”
问题描述
我正在尝试根据此处的文档交换 Salesforce Marketing Cloud (SFMC) authorization_code
:access_token
https: //developer.salesforce.com/docs/atlas.en-us.mc-app-development.meta/mc-app-development /access-token-app.htm
curl https://{my_subdomain}.auth.marketingcloudapis.com/v2/token \
--request POST \
--header "Content-Type: application/json" \
--data '{"grant_type": "authorization_code", "code": "{{my_code}}", "client_id": "{{my_client_id}}", "redirect_uri": "https://127.0.0.1:80/", “client_secret: “{{my_client_secret}}”, "scope": "audiences_read list_and_subscribers_write offline"}'
然而它不断地给我以下错误:
{"documentation":"https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/error-handling.htm","errorcode":0,"message":"Bad Request"}%
我不知道我哪里出错了,感谢任何帮助。
当我使用过期的和/或错误的时候,我看到了“正确”code
的client_id
错误client_secret
,但是在我粘贴了正确的值之后什么都没有。也许这是我的范围?
根据错误代码中链接的文档,The token was not found in the request, or it is invalid or expired.
. 这是唯一具有customcode == 0
. 这很奇怪,因为我试图获取 a token
,而不是传递一个,并且该错误代码与 a 相关联401
,这可能是也可能不是我收到的内容。
解决方案
原来我client_secret
在我的数据中使用了不正确的双引号。这是一个倾斜的双引号。当我尝试使用Python3
而不是cURL
将上面的 JSON 转换为 JSON 以传递给requests
库时,我发现了这一点。我能够成功获得令牌。
所以答案是,以上是正确的,只要注意你的编码!
推荐阅读
- php - 设置 php 变量仅包含选定的数组
- angular - 我在帖子上有一个错误的请求 400
- javascript - How to export the value of an observable and assign to a variable?
- mysql - MySQL - 如何有效地离开基于字段的不同记录(无 n+1)?
- javascript - Using state in child component received from parent component
- jmeter - Jmeter blob上传不允许上传
- sql - Django查询:具有给定电子邮件的所有用户
- ruby-on-rails - 应用 deep_symbolize_keys!散列数组
- php - How to get PHP to match textbox with corresponding checkbox from a form
- javascript - addEventListener() 如何自动接收事件对象参数?