尝试从https://github.com/Instagram/python-instagram
运行示例程序时在我尝试点击http://localhost:8515/上运行的任何链接之前,一切正常。我可以成功登录,但如果我点击任何链接,例如" User Recent Media"我收到以下错误:
KeyError('access_token',)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/bottle.py", line 862, in _handle
return route.call(**args)
File "/usr/local/lib/python3.4/site-packages/bottle.py", line 1732, in wrapper
rv = callback(*a, **ka)
File "sample_app.py", line 75, in on_recent
access_token = request.session['access_token']
File "/usr/local/lib/python3.4/site-packages/beaker/session.py", line 672, in __getitem__
return self._session()[key]
KeyError: 'access_token'
我在OSX Yosemite上运行Python3.4。我的Instgram客户端使用以下URI和网站:
答案 0 :(得分:1)
您遇到的问题是,在您的 sample.py 中,您尝试访问request.session字典中的access_token,但它不存在。为避免错误,您可以执行以下操作:
2.0