user985030
user985030

Reputation: 1617

python-instagram 500 Internal server error

When attempting to run the sample program from https://github.com/Instagram/python-instagram

Everything works fine until I try to click on any of the links that are running on my http://localhost:8515/. I can successfully login, but if I click any of the links like "User Recent Media" I get the following error:

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'

I am running Python3.4 on OSX Yosemite. My Instgram client uses the following URI and website:

Upvotes: 0

Views: 623

Answers (1)

Ricardo Burillo
Ricardo Burillo

Reputation: 1386

The problem that you have here is that in your sample.py you are trying to access to access_token in the request.session dictionary and it doesn't exists. To avoid the error you can do something like:

if 'access_token' in request.session.keys():
     access_token = request.session['access_token']

Upvotes: 1

Related Questions