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

无法获取Instagram长时访问令牌:GET请求方法不支持

解决Instagram长时访问令牌换取的"Unsupported request - method type: get"错误

问题原因

Instagram的API近期调整了请求方式要求,换取长时访问令牌的接口不再支持GET请求,必须使用POST方法提交参数。

官方文档要求(翻译)

Instagram平台商业登录的官方文档明确规定:

换取长时访问令牌时,需向https://graph.instagram.com/access_token发送POST请求,参数需以application/x-www-form-urlencoded格式提交,包含grant_type=ig_exchange_token、client_secret、access_token三个必填项。

修复后的代码

将原GET请求改为POST请求,参数以表单形式传递:

let getAccountLongLivedToken = await axios.post(
  'https://graph.instagram.com/access_token',
  new URLSearchParams({
    grant_type: 'ig_exchange_token',
    client_secret: process.env.INSTAGRAM_APP_SECRET,
    access_token: instagramData.access_token
  }),
  {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }
);

补充说明

尽管此前GET请求能正常运行,但Meta已严格执行文档规定的请求方式,因此必须切换为POST请求才能成功换取长时令牌。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.11 16:32:33