OAuthAccessTokenException - 提供的access_token无效

时间:2017-11-04 03:48:33

标签: python api oauth instagram

我试图在他们的readme上跟随Python-Instagram简单示例:

api = InstagramAPI(client_id=client_id, client_secret=client_secret) popular_media = api.media_popular(count=20) for media in popular_media: print media.images['standard_resolution'].url

但是,每次我尝试使用自己的client_id和client_secret时,都会出现以下错误,并且无法弄清楚如何解决它:

Traceback (most recent call last): File "/Users/PycharmProjects/Instagram API/InstaApiTest.py", line 10, in <module> popular_media = api.media_popular(count=20) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/instagram/bind.py", line 197, in _call return method.execute() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/instagram/bind.py", line 189, in execute content, next = self._do_api_request(url, method, body, headers) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/instagram/bind.py", line 163, in _do_api_request raise InstagramAPIError(status_code, content_obj['meta']['error_type'], content_obj['meta']['error_message']) instagram.bind.InstagramAPIError: (400) OAuthAccessTokenException-The access_token provided is invalid.

任何人都可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

这很可能是因为教程已经过时了。请注意,教程仓库中的README file(未经过多年更新)会发出警告:

  

此项目未得到积极维护。继续自担风险!

Instagram甚至不再在media endpoints official documentation上列出media/popular/了。即使它是一个东西,你需要一个实际的访问令牌,即使是几年前,与你所遵循的教程相反。some indication

TL; DR - 查找其他教程,此端点已更改或需要完整身份验证。