根据此处的文档,我正在尝试将Salesforce Marketing Cloud的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的错误代码。这很奇怪,因为我正在尝试获取一个token,而不是传入一个,并且错误代码与一个401相关联,这可能是也可能不是我收到的结果。
发布于 2020-02-04 05:26:49
事实证明,我的数据中的client_secret使用了错误的双引号。这是一个倾斜的双引号。当我尝试使用Python3而不是cURL,并将上面的JSON转换为JSON以传递给requests库时,我发现了这一点。我成功地拿到了一个代币。
所以答案是,上面的是正确的,只需要注意你的编码!
https://stackoverflow.com/questions/60047215
复制相似问题