Meta Threads API令牌兑换报错问题求助
Threads API长令牌兑换权限异常问题
我司已审核上线的Threads应用,近期调用Threads API兑换长生命周期令牌时错误率上升,报错信息如下:
{'error': {'message': 'This action requires the threads_basic permission. You must submit for app review, or your user must be in the list of Threads testers.', 'type': 'THApiException', 'code': 100, 'error_subcode': 10, 'fbtrace_id': 'A4sT6JWDbjlaFgtEBNxAElZ'}}
异常说明:应用已通过审核上线,且用户已完成权限授权(使用新的公开Threads账号测试,接受全部权限后仍可复现该报错)。
授权链接代码(URL编码)
base = "https://threads.net/oauth/authorize" params = { "client_id": os.environ.get("THREADS_CLIENT_ID"), "redirect_uri": os.environ.get("THREADS_REDIRECT_URI"), "scope": "threads_basic,threads_content_publish", "response_type": "code" } url = f"{base}?{parse.urlencode(params)}"
该链接可正常跳转至Threads权限授权页面,完成授权后,后端按官方「获取长生命周期令牌」流程执行以下代码:
长令牌兑换代码
url = "https://graph.threads.net/oauth/access_token" data = { "client_id": os.environ.get("THREADS_CLIENT_ID"), "client_secret": os.environ.get("THREADS_CLIENT_SECRET"), "code": code, "grant_type": "authorization_code", "redirect_uri": os.environ.get("THREADS_REDIRECT_URI"), } resp = requests.post(url, data=data) logging.info(f"Response threads : {resp.json()}") resp.raise_for_status() short_token = resp.json() base = "https://graph.threads.net/access_token" params = { "grant_type": "th_exchange_token", "client_secret": os.environ.get("THREADS_CLIENT_SECRET"), "access_token": short_token["access_token"] } url_long_lived = f"{base}?{parse.urlencode(params)}" response_long = requests.get(url_long_lived) thread_value = response_long.json() if "access_token" not in thread_value: logging.error(f"Threads output : {thread_value}") return {"error": "bad-request"}, 420
测试情况:获取short-lived access token步骤正常,但兑换long-lived token时出现上述报错。使用Postman测试相同请求,结果一致。
我怀疑问题出在以下两个方向:
- short-lived access token未绑定正确权限范围,导致兑换长令牌时报错
- 长令牌兑换端点本身存在问题
恳请帮忙分析原因。
内容的提问来源于stack exchange,提问作者Tom3652
相关产品推荐
相关产品推荐

