Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
smidm opened this issue Feb 19, 2015 · 12 comments

Comments

@smidm
Copy link
Contributor

smidm commented Feb 19, 2015

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
@akselx
Copy link

akselx commented Apr 13, 2015

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

@kjgarza
Copy link

kjgarza commented Jun 24, 2015

I have the same issue, any solution yet?

@kjgarza
Copy link

kjgarza commented Jun 24, 2015

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

@silpol
Copy link

silpol commented Jul 15, 2015

@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).

@silpol
Copy link

silpol commented Jul 15, 2015

@smidm , @akselx and @kjgarza - have you managed to get down the bottom of this bug?
or do we have to disturb @MendeleyStack to help us?

@Joyce-Stack
Copy link
Contributor

Hello,

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

@Joyce-Stack
Copy link
Contributor

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

@Joyce-Stack
Copy link
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

@livia-b
Copy link

livia-b commented Feb 6, 2016

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)

@StankoPalko
Copy link

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

@michaelplews
Copy link

@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?

@smidm
Copy link
Contributor Author

smidm commented Dec 27, 2016

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants