【问题标题】:Instagram API: Invalid Platform App when fetching access tokenInstagram API:获取访问令牌时平台应用程序无效
【发布时间】:2020-06-12 01:37:58
【问题描述】:

我正在尝试使用 Instagram Basic Display API 登录。

我正在尝试获取access_token,并且我正在使用 axios:

const { code } = queryParams;
      const url = `https://instagram.com/oauth/access_token`;
      const result = await axios.request({
        url,
        method: 'POST',
        data: {
          'client_id': INSTAGRAM_CLIENT_ID,
          'client_secret': INSTAGRAM_CLIENT_SECRET,
          'grant_type': 'authorization_code',
          'redirect_uri': 'https://localhost:3000/auth/instagram/token',
          code,
        },
      });

我收到400 错误,消息为invalid platform app。发送的所有值都存在且正确。

虽然我的redirect_uri 不存在,但它已添加到授权 URL 列表中。它不存在,因为我的本地服务器中没有 https。

【问题讨论】:

    标签: node.js instagram-api


    【解决方案1】:

    我也有同样的问题。 The official example given by Instagram 使用 curl 使用 -F 标签,这意味着他们将数据作为 application/x-www-form-urlencoded 内容类型发布。

    我尝试过的所有其他帖子格式都被忽略了。将代码更改为以表单形式发布,它应该可以工作。

    【讨论】:

      【解决方案2】:

      this post上有一个很好的答案

      const querystring = require('querystring');

      //使用参数制作对象 const data = { client_id: 'xxxxxxx', client_secret: 'xxxxxxxxxxx', grant_type: '授权码', redirect_uri: 'https://example.com/auth', 代码:'xxxx' }

      //拨打电话 axios.post("https://api.instagram.com/oauth/access_token", querystring.stringify(data)) .then(function (response) { console.log("OK", response.data); }) .catch(函数(错误){ 控制台日志(错误); });

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-09-19
        • 2020-10-30
        • 2017-04-28
        • 1970-01-01
        • 2016-02-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多