Sandbox中的OAuthPermissionsException Instagram API

Mar*_*off 50 instagram-api

我会很感激我在一段时间内试图解决的问题上的一些输入/指示.

我正在尝试使用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.'}}
Run Code Online (Sandbox Code Playgroud)

这是我编写的简单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()
Run Code Online (Sandbox Code Playgroud)

我使用沙盒的正确URL吗?我阅读了Instagram API文档,Sandbox中的应用程序不需要任何类型的范围更改批准.

此外,该应用程序仅授权Sandbox:

Instagram API中定义的应用程序的屏幕截图

任何方向将不胜感激.

谢谢,

马丁

更新:弄清楚发生了什么.首先需要更改应用程序的授权范围.我就这样做了:

只需要以大写形式插入单词的数据

完成后,应用程序将获得该范围的授权.

因为我已经有访问令牌,所以我不需要执行第2步和第3步.

希望这可以帮助.

马丁

Mar*_*off 82

更新:弄清楚发生了什么.首先需要更改应用程序的授权范围.我就这样做了:

从您的浏览器执行:

https://api.instagram.com/oauth/authorize/?client_id=CLIENTID&redirect_uri=REDIRECT-URI&response_type=code&scope=SCOPE

只需要以大写形式插入单词的数据

完成后,应用程序将获得该范围的授权.

因为我已经有访问令牌,所以我不需要执行第2步和第3步.

希望这可以帮助.

马丁

  • 此问题没有详细记录.它让很多人感到困惑所以我为开发人员撰写了一篇关于[新Instagram API如何工作]的简短摘要(https://medium.com/@emersonthis/instagram-on-websites-the-new-landscape-62c91d733894# .4z8g35g2s). (6认同)