gpt4 book ai didi

instagram - Instagram 错误 : The access_token provided is invalid

转载 作者:行者123 更新时间:2023-12-02 22:29:36 25 4
gpt4 key购买 nike

我一年前建立了一个网站,其中的 Instagram feed 显示来自该网站帐户的图像。它一直工作得很好,直到上周我开始抛出:来自 Instagram 的错误:提供的 access_token 无效。不知从何而来。

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

登录管理员帐户时。它不起作用。

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

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

{"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();

最佳答案

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

https://www.instagram.com/developer/clients/{clientId}/edit/在“安全”下;您将选中禁用隐式 OAuth。其描述为:

Disable the Client-Side (Implicit) OAuth flow for web apps. If you check this option, Instagram will better protect your application by only allowing authorization requests that use the Server-Side (Explicit) OAuth flow. The Server-Side flow is considered more secure. See the Authentication documentation for details.

要解决您面临的错误:隐式身份验证已禁用,您需要使用服务器端身份验证。这是您请求中的 response_type=code 而不是 response_type=token

<小时/>

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

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

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

关于instagram - Instagram 错误 : The access_token provided is invalid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49056340/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com