我会很感激我在一段时间内试图解决的问题上的一些输入/指示 .
我正在尝试使用Instagram API访问与标签相关的数据(让我们称之为“X”) . 我尝试直接从Python和浏览器运行它并得到相同的错误:
{u'meta': {u'code': 400, u'error_type':u'OAuthPermissionsException',
u'error_message': u'This request requires scope=public_content, but this
access token is not authorized with this scope. The user must re-authorize
your application with scope=public_content to be granted this permissions.'}}
这是我编写的简单Python代码,以便首先使其工作:
import requests
access_token = 'zzzzzzzzzzzzz'
parameters = {"q": "X",
"scope": "public_content",
"access_token": "zzzzzzzzzzzzz"}
response = requests.get("https://api.instagram.com/v1/tags/search",
params=parameters)
insta_posts = response.json()
我是否使用正确的沙盒网址?我阅读了Instagram API文档,Sandbox中的应用程序不需要任何类型的范围更改批准 .
此外,该应用程序仅授权Sandbox:
Screen Capture of Application Defined in Instagram API
任何方向将不胜感激 .
谢谢,
马丁
UPDATE :弄清楚发生了什么 . 首先需要更改应用程序授权的范围 . 这就是我做的方式:
- 从您的浏览器执行:
只需要以大写形式插入单词的数据
完成后,该应用程序将获得该范围的授权 .
因为我已经有访问令牌,所以我不需要执行第2步和第3步 .
希望这可以帮助 .
马丁
3 回答
更新:弄清楚发生了什么 . 首先需要更改应用程序授权的范围 . 这就是我做的方式:
从您的浏览器执行:
https://api.instagram.com/oauth/authorize/?client_id=CLIENTID&redirect_uri=REDIRECT-URI&response_type=code&scope=SCOPE
只需要以大写形式插入单词的数据
完成后,该应用程序将获得该范围的授权 .
因为我已经有访问令牌,所以我不需要执行第2步和第3步 .
希望这可以帮助 .
马丁
这是一个很好的例子:
https://www.instagram.com/oauth/authorize?client_id=b23670e258o0fmk334jfu287c9f9953&redirect_uri=http://127.0.0.1:5000&response_type=code&scope=basic+public_content+follower_list+comments+relationships+likes
只需在URL末尾添加范围参数:
显而易见,您从其接收access_token的应用程序不允许使用public_content范围