You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TikTok Business API调用报错40131:授权码已过期求助

TikTok商家账号API授权问题

使用TikTok商家账号API的授权流程中,授权URL已成功返回code,授权链接如下:

https://business-api.tiktok.com/portal/auth?app_id=*&redirect_uri=*&state=*

但调用后续获取refresh token和access token的接口时,所有请求均返回错误:

Array
(
    [code] => 40131
    [message] => Authorization code is expired.
    [request_id] => 20231128065023E81AF5A697F6751ACD17
)

请求使用的curl命令如下:

curl --location --request POST 'https://business-api.tiktok.com/open_api/v1.3/tt_user/oauth2/token/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "client_id": "***",
    "client_secret": "***",
    "grant_type": "authorization_code",
    "auth_code": "***",
    "redirect_uri": "http://localhost:8000/tikTokBusinessAccount"
}'

预期结果应为无错误返回,以下是针对性解决建议:

  • 授权码auth_code需在获取后立即调用token接口:TikTok授权码有效期极短,若间隔时间过长会直接过期。
  • 确保auth_code未重复使用:授权码为一次性凭证,哪怕首次调用失败,也必须重新获取新的code。
  • 严格匹配redirect_uri参数:必须与授权URL中使用的redirect_uri完全一致,包括域名、路径、大小写,任何差异都可能触发验证失败。
  • 核对所有请求参数:确认grant_type为authorization_code,client_id和client_secret与应用后台配置完全匹配,无拼写错误或多余字符。

内容的提问来源于stack exchange,提问作者WhoLetTheDogsOut

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 02:55:07