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

Instagram Graph API短期令牌转长期令牌失败:不支持GET请求

Instagram短期令牌兑换长期令牌报错"Unsupported request - method type: get"的解决办法

错误详情

你遇到的错误是调用长期令牌兑换接口时方法类型不被支持:

error: {
  message: 'Unsupported request - method type: get',
  type: 'IGApiException',
  code: 100,
  fbtrace_id: 'AnMYrIXYSTKYCA_Sh2qKxkU'
}

问题根源

Instagram Graph API的ig_exchange_token接口(用于短期令牌转长期令牌)不支持GET请求,必须通过POST方式提交参数,参数不能放在URL查询字符串里。

修改后的代码

把GET请求改成POST,参数移到请求体中,格式和你获取短期令牌的逻辑保持一致:

const userPlatform = await this.userPlatformService.getUserPlatfromsByCode(userId, "INSTAGRAM");

// 修改后的长期令牌兑换请求配置
const userLongLiveTokenApi = {
    url: 'https://graph.instagram.com/access_token',
    method: 'post',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: new URLSearchParams({
        grant_type: 'ig_exchange_token',
        client_secret: instagramConfig.clientSecret,
        access_token: userPlatform.authToken
    }).toString()
};

console.log(userLongLiveTokenApi);

const userLongLiveTokenResponse = await this.apiCall(userLongLiveTokenApi);

关键改动点

  • 请求方法从'get'改为'post'
  • 移除URL中的查询参数,将参数通过URLSearchParams序列化后放入请求体
  • 添加Content-Type: application/x-www-form-urlencoded请求头

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 15:27:08