Skip to content

KeyError: 'state' on mendeley.start_authorization_code_flow(state=session['state']) #3

Open

Description

@smidm
127.0.0.1 - - [19/Feb/2015 12:50:13] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [19/Feb/2015 12:50:16] "GET /oauth?state=.....&code=..... HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/..../mendeley-api-python-example/mendeley-example.py", line 33, in auth_return
    auth = mendeley.start_authorization_code_flow(state=session['state'])
  File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/werkzeug/local.py", line 368, in <lambda>
    __getitem__ = lambda x, i: x._get_current_object()[i]
KeyError: 'state'

My installed modules:

(mendeley-api-python-example) ↪ pip freeze
-f /home/matej/.pip/wheels
Flask==0.10.1
Jinja2==2.7.3
MarkupSafe==0.23
PyYAML==3.11
Werkzeug==0.10
argparse==1.2.1
arrow==0.5.0
certifi==14.05.14
future==0.14.3
itsdangerous==0.24
memoized-property==1.0.2
mendeley==0.3.0
oauthlib==0.7.2
python-dateutil==2.4.0
requests==2.5.1
requests-oauthlib==0.4.2
six==1.9.0
wheel==0.24.0
wsgiref==0.1.2

Activity

  1. akselx commented on Apr 13, 2015

    @akselx

    I got the same issue, Ubuntu 14.04, python 2.7.

  2. kjgarza commented on Jun 24, 2015

    @kjgarza

    I have the same issue, any solution yet?

  3. kjgarza commented on Jun 24, 2015

    @kjgarza

    Curly brackets are not required!!!!!
    clientId: 1111
    clientSecret: nddfdf7979df

  4. silpol commented on Jul 15, 2015

    @silpol

    Kristian Garza (@kjgarza) curly brackets cause issue #2
    Once I have removed them, I got towards login and after login I bumped into issue described in this report, literally (minus hashes and other possible ephemerals).

  5. silpol commented on Jul 15, 2015

    @silpol

    Matěj Šmíd (@smidm) , Aksel Olsen (@akselx) and Kristian Garza (@kjgarza) - have you managed to get down the bottom of this bug?
    or do we have to disturb @MendeleyStack to help us?

  6. Joyce-Stack commented on Jul 16, 2015

    @Joyce-Stack
    Contributor

    Hello,

    I'm trying to find someone with Ubuntu installed in our team. Stand by.

  7. Joyce-Stack commented on Jul 27, 2015

    @Joyce-Stack
    Contributor

    I am currently looking into this but I need to fix this issue first as I can't proceed until then - #4

  8. Joyce-Stack commented on Jul 27, 2015

    @Joyce-Stack
    Contributor

    I have had colleagues run this example and get successful responses using:-

    • Python 2.7.6 with Linux Mint 17.1 Rebecca
    • Ubuntu 14.10 with Python 2.7.8

    I re-cloned this project on my Macbook and was able to rerun it successfully. Also, I went to the developer portal and regenerated my secret.

    • Go to the dev.mendeley.com
    • Hit the Sign In button
    • Hit the Generate Secret button and copy the new secret into the config.yml file
    • Click Update

    Can you try and do a pip uninstall all - http://stackoverflow.com/questions/11248073/what-is-the-easiest-way-to-remove-all-packages-installed-by-pip

  9. livia-b commented on Feb 6, 2016

    @livia-b

    I also came across this problem, and somehow it worked after regenerating the secret, clearing cookies, changing browser ... hope that helps (mac, python 2.7, chrome and firefox)

  10. StankoPalko commented on Apr 9, 2016

    @StankoPalko

    This is due to redirect url. If you are running locally like I am your site runs on: http://127.0.0.1:5000/
    but your redirect URL is set to http://localhost:5000/oauth which are two sites in terms of cookies so cookies can't be found and hence the key error. Change it to http://127.0.0.1:5000/oauth

  11. michaelplews commented on Jul 7, 2016

    @michaelplews

    StankoPalko do you mean change the URI to http://1270.0.1:5000/oauth in the mendeley-example.py file? or on dev.mendeley.com?

  12. smidm commented on Dec 27, 2016

    @smidm
    ContributorAuthor

    This solved the issue for me:

    • removing and installing packages with pip (not sure if necessary, definitely not sufficient alone)
    • clearing all cookies for *mendeley.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions