【问题标题】:instafeed.js stopped working: The access_token provided is invalidinstafeed.js 停止工作:提供的 access_token 无效
【发布时间】:2018-01-22 14:55:45
【问题描述】:

我正在像这样使用 instafeed.js:

var feed = new Instafeed({
        get: 'user',
        userId: 19191919191,
        limit: 9,
        accessToken: 'myaccesstokenhere',
        target: 'instagram',
        resolution: 'standard_resolution',
        after: function() {
            var el = document.getElementById('instagram');
            if (el.classList)
                el.classList.add('show');
            else
                el.className += ' ' + 'show';
        }
});

但我收到此错误:

The access_token provided is invalid.

我通过https://www.instagram.com/developer 获得了access_token 我注册了我的应用程序并将客户端密码作为accessToken 并从这里https://smashballoon.com/instagram-feed/find-instagram-user-id/ 获得了我的用户ID

但它仍然在说The access_token provided is invalid.我做错了什么?

【问题讨论】:

  • 来自文档:Even though our access tokens do not specify an expiration time, your app should handle the case that either the user revokes access, or Instagram expires the token after some period of time. If the token is no longer valid, API responses will contain an “error_type=OAuthAccessTokenException”. In this case you will need to re-authenticate the user to obtain a new valid token. In other words: do not assume your access_token is valid forever.instagram.com/developer/authentication
  • 我做到了,我创建了一个全新的应用程序和令牌。
  • 这里已经回答了,拍个look

标签: javascript jquery instagram instagram-api instafeedjs


【解决方案1】:

您不能使用您的客户端密码代替accessToken,因为客户端密码在服务器端用作 OAuth 过程的一部分,以获取用户 accessToken。

我建议查看 Instagram 的身份验证文档 here,以确保您使用的身份验证策略对您的应用程序有意义。

听起来您更可能想要使用他们的客户端隐式身份验证(在bottom)来获取访问令牌。您甚至可以自己手动执行此操作,以获得accessToken 进行测试。获得 accessToken 后,您只需在 instafeed.js 的正确字段中使用它即可从 Instagram 加载您想要的内容。

您也可以通过转到http://instagram.pixelunion.net/ 并使用那里生成的访问令牌来获取自己的访问令牌。

【讨论】:

    【解决方案2】:

    您似乎将accessTokenClient Secret 混淆了,请在此处查看https://www.instagram.com/developer/authentication/

    为了让生活更轻松,您可以尝试在此处生成一个http://instagram.pixelunion.net/

    【讨论】:

      猜你喜欢
      • 2023-03-11
      • 2016-11-07
      • 1970-01-01
      • 2016-10-03
      • 1970-01-01
      • 1970-01-01
      • 2020-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多