{"action":"created","issue":{"url":"https://api.github.com/repos/Mendeley/mendeley-api-python-example/issues/3","repository_url":"https://api.github.com/repos/Mendeley/mendeley-api-python-example","labels_url":"https://api.github.com/repos/Mendeley/mendeley-api-python-example/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/Mendeley/mendeley-api-python-example/issues/3/comments","events_url":"https://api.github.com/repos/Mendeley/mendeley-api-python-example/issues/3/events","html_url":"https://github.com/Mendeley/mendeley-api-python-example/issues/3","id":58198977,"number":3,"title":"KeyError: 'state' on mendeley.start_authorization_code_flow(state=session['state'])","user":{"login":"smidm","id":820292,"avatar_url":"https://avatars.githubusercontent.com/u/820292?v=3","gravatar_id":"","url":"https://api.github.com/users/smidm","html_url":"https://github.com/smidm","followers_url":"https://api.github.com/users/smidm/followers","following_url":"https://api.github.com/users/smidm/following{/other_user}","gists_url":"https://api.github.com/users/smidm/gists{/gist_id}","starred_url":"https://api.github.com/users/smidm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smidm/subscriptions","organizations_url":"https://api.github.com/users/smidm/orgs","repos_url":"https://api.github.com/users/smidm/repos","events_url":"https://api.github.com/users/smidm/events{/privacy}","received_events_url":"https://api.github.com/users/smidm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-02-19T11:55:35Z","updated_at":"2016-04-09T09:26:22Z","closed_at":null,"body":"```\r\n127.0.0.1 - - [19/Feb/2015 12:50:13] \"GET / HTTP/1.1\" 200 -\r\n127.0.0.1 - - [19/Feb/2015 12:50:16] \"GET /oauth?state=.....&code=..... HTTP/1.1\" 500 -\r\nTraceback (most recent call last):\r\n  File \"/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py\", line 1836, in __call__\r\n    return self.wsgi_app(environ, start_response)\r\n  File \"/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py\", line 1820, in wsgi_app\r\n    response = self.make_response(self.handle_exception(e))\r\n  File \"/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py\", line 1403, in handle_exception\r\n    reraise(exc_type, exc_value, tb)\r\n  File \"/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py\", line 1817, in wsgi_app\r\n    response = self.full_dispatch_request()\r\n  File \"/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py\", line 1477, in full_dispatch_request\r\n    rv = self.handle_user_exception(e)\r\n  File \"/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py\", line 1381, in handle_user_exception\r\n    reraise(exc_type, exc_value, tb)\r\n  File \"/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py\", line 1475, in full_dispatch_request\r\n    rv = self.dispatch_request()\r\n  File \"/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py\", line 1461, in dispatch_request\r\n    return self.view_functions[rule.endpoint](**req.view_args)\r\n  File \"/..../mendeley-api-python-example/mendeley-example.py\", line 33, in auth_return\r\n    auth = mendeley.start_authorization_code_flow(state=session['state'])\r\n  File \"/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/werkzeug/local.py\", line 368, in <lambda>\r\n    __getitem__ = lambda x, i: x._get_current_object()[i]\r\nKeyError: 'state'\r\n```\r\n\r\nMy installed modules:\r\n```\r\n(mendeley-api-python-example) ↪ pip freeze\r\n-f /home/matej/.pip/wheels\r\nFlask==0.10.1\r\nJinja2==2.7.3\r\nMarkupSafe==0.23\r\nPyYAML==3.11\r\nWerkzeug==0.10\r\nargparse==1.2.1\r\narrow==0.5.0\r\ncertifi==14.05.14\r\nfuture==0.14.3\r\nitsdangerous==0.24\r\nmemoized-property==1.0.2\r\nmendeley==0.3.0\r\noauthlib==0.7.2\r\npython-dateutil==2.4.0\r\nrequests==2.5.1\r\nrequests-oauthlib==0.4.2\r\nsix==1.9.0\r\nwheel==0.24.0\r\nwsgiref==0.1.2\r\n```"},"comment":{"url":"https://api.github.com/repos/Mendeley/mendeley-api-python-example/issues/comments/207752071","html_url":"https://github.com/Mendeley/mendeley-api-python-example/issues/3#issuecomment-207752071","issue_url":"https://api.github.com/repos/Mendeley/mendeley-api-python-example/issues/3","id":207752071,"user":{"login":"StankoPalko","id":8886435,"avatar_url":"https://avatars.githubusercontent.com/u/8886435?v=3","gravatar_id":"","url":"https://api.github.com/users/StankoPalko","html_url":"https://github.com/StankoPalko","followers_url":"https://api.github.com/users/StankoPalko/followers","following_url":"https://api.github.com/users/StankoPalko/following{/other_user}","gists_url":"https://api.github.com/users/StankoPalko/gists{/gist_id}","starred_url":"https://api.github.com/users/StankoPalko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StankoPalko/subscriptions","organizations_url":"https://api.github.com/users/StankoPalko/orgs","repos_url":"https://api.github.com/users/StankoPalko/repos","events_url":"https://api.github.com/users/StankoPalko/events{/privacy}","received_events_url":"https://api.github.com/users/StankoPalko/received_events","type":"User","site_admin":false},"created_at":"2016-04-09T09:26:22Z","updated_at":"2016-04-09T09:26:22Z","body":"This is due to redirect url. If you are running locally like I am  your site runs on: http://127.0.0.1:5000/\r\nbut 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\r\n\r\n"}}