【问题标题】:Error from Instagram: The access_token provided is invalidInstagram 的错误:提供的 access_token 无效
【发布时间】:2018-03-01 18:26:53
【问题描述】:

我在一年前建立了一个网站,其中包含一个 Instagram 提要,显示来自该网站帐户的图像。它一直运行良好,直到上周我开始投掷:Error from Instagram: The access_token provided is invalid. 不知从何而来。

我环顾四周,发现(相当合乎逻辑地)我需要重新生成令牌。我尝试通过instagram.pixelunion

这样做

以管理员帐户登录时。它没有用。

所以我尝试了这个: https://www.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token

我认为该网站的工作原理是将 clientId 粘贴到client_id=xxx之后的 url 并刷新页面,但这样做会返回:

{"error_type": "OAuthForbiddenException", "code": 403, "error_message": "Implicit authentication is disabled"}

这是我获取图片的代码(我也有一个 instafeed.min.js):

    var feed = new Instafeed({
    target: "insta-images",
    get: 'user',
    userId: "xxxxxx",
    clientId: "xxxxxxxxxxxxxxxxxxxxxxxx",
    accessToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    resolution: "standard_resolution",
    limit: 8,
    template: '<li id="insta"><a href="{{link}}"><img src="{{image}}"/></a></li>'
});


feed.run();

【问题讨论】:

    标签: instagram instagram-api


    【解决方案1】:

    如果您查看您的应用程序设置:

    https://www.instagram.com/developer/clients/{clientId}/edit/ 在“安全”下;你会检查Disable implicit OAuth。描述为:

    禁用 Web 应用程序的客户端(隐式)OAuth 流。如果您选中此选项,Instagram 将通过仅允许使用服务器端(显式)OAuth 流的授权请求来更好地保护您的应用程序。服务器端流程被认为更安全。有关详细信息,请参阅身份验证文档。

    要解决您面临的错误:Implicit authentication is disabled 您需要使用服务器端身份验证。在您的请求中是 response_type=code 而不是 response_type=token


    关于response_type 的 OAuth 2.0 差异的更多详细信息:

    response_type=code 将为您提供临时代码,您使用令牌端点从代码 (https://www.instagram.com/developer/authentication/) 接收令牌:

    curl -F 'client_id=CLIENT_ID' \
    -F 'client_secret=CLIENT_SECRET' \
    -F 'grant_type=authorization_code' \
    -F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \
    -F 'code=CODE' \
    https://api.instagram.com/oauth/access_token
    

    【讨论】:

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