Tiktok OAuth v2 请求参数格式错误

问题描述 投票:0回答:1

尝试从 Tiktok 的 API 从 v1 端点迁移到 v2 端点。目前版本 1 适用于我,但我对 https://open.tiktokapis.com/v2/oauth/token/ 端点的请求不断返回

{
    "error": "invalid_request",
    "error_description": "The request parameters are malformed.",
    "log_id": "202308141814065FE27A58513347021AF1"
}

我正在通过 Postman 进行测试,以下是我的请求的屏幕截图:

用于获取传递到postman请求中的“code”的url是 https://www.tiktok.com/v2/auth/authorize/?client_key=abcdefg&scope=user.info.basic,user.info.profile,user.info.stats,video.list&response_type=code&state=abcdefg&redirect_uri=https: //www.test.com/redirect

我已请求 Tiktok 支持 log_id,他们说这是因为“请求中未设置授权类型”。我在 Postman 的标头中使用 applicaiton/x-www-form-urlencoded,所以如果这是问题,我不确定还需要修改什么。

oauth postman tiktok tiktok-api
1个回答
0
投票

我认为你的问题是因为你在 query 参数中传递参数,它们必须在主体参数中

你也可以尝试在postman中导入这个curl,官方文档中有:

curl --location --request POST 'https://open.tiktokapis.com/v2/oauth/token/' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cache-Control: no-cache' \
--data-urlencode 'client_key=CLIENT_KEY' \
--data-urlencode 'client_secret=CLIENT_SECRET' \
--data-urlencode 'code=CODE' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'redirect_uri=REDIRECT_URI'

参考:https://developers.tiktok.com/doc/oauth-user-access-token-management

© www.soinside.com 2019 - 2024. All rights reserved.