KeyError:'oauth_state'

时间:2018-04-16 03:40:39

标签: python flask

您好我正在尝试在https://github.com/futurice/whereareyou

上测试代码

我在主服务器端遇到问题。

收到错误

Traceback (most recent call last):
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1997, in call
return self.wsgi_app(environ, start_response)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/arms/Project/whereareyou/app.py", line 112, in callback
google = get_google_auth(state=session['oauth_state'])
File "/home/arms/.local/lib/python2.7/site-packages/werkzeug/local.py", line 377, in 
getitem = lambda x, i: x._get_current_object()[i]
KeyError: 'oauth_state'

请帮忙。谢谢。

1 个答案:

答案 0 :(得分:0)

在我的应用中使用带有Flask提供的以下链接的会话时,我遇到了同样的问题:

http://127.0.0.1:5000/

解决方案:不过,它与http://localhost:5000/

完美搭配

只需将您的本地IP地址(127.0.0.1)替换为“ 本地主机”。