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
相关产品推荐
相关产品推荐

