我按照本教程(https://artandlogic.com/2014/04/tutorial-adding-facebooktwittergoogle-authentication-to-a-django-application/)进行操作,并且收到以下错误。我已将服务器托管在 EC2 实例上,并且有一个域http://(xyz).com。我还看到了这个问题的答案(使用 django python-social-auth 重定向后会话值丢失),但我没有得到任何帮助。\n
这是文本中的堆栈跟踪
\n\n AuthStateMissing at /api/user/complete/google-oauth2/\nSession value state missing.\nRequest Method: GET\nRequest URL: http://interviewmiles.com:8000/api/user/complete/google-oauth2/?state=9Sa5JSkbcAbbGzBtqpx6jtbLCuJPe6kJ&code=4/c4VTig14u7THYLd1M4VoTRf1dnq58wp6S68EbkSwhZs&authuser=0&session_state=8aa4e419c219643dc264950a24151457677d99ae..b805&prompt=none\nDjango Version: 1.9.7\nException Type: AuthStateMissing\nException Value: \nSession value state missing.\nException Location: /usr/local/lib/python2.7/site-packages/social/backends/oauth.py in validate_state, line 88\nPython Executable: /usr/bin/python\nPython Version: 2.7.10\nPython Path: \n[\'/home/ec2-user/interviewmiles/login\',\n \'/usr/local/lib/python2.7/site-packages/django_cors_headers-1.1.0-py2.7.egg\',\n \'/usr/lib64/python27.zip\',\n \'/usr/lib64/python2.7\',\n \'/usr/lib64/python2.7/plat-linux2\',\n \'/usr/lib64/python2.7/lib-tk\',\n \'/usr/lib64/python2.7/lib-old\',\n \'/usr/lib64/python2.7/lib-dynload\',\n \'/usr/local/lib64/python2.7/site-packages\',\n \'/usr/local/lib/python2.7/site-packages\',\n \'/usr/lib64/python2.7/site-packages\',\n \'/usr/lib/python2.7/site-packages\',\n \'/usr/lib64/python2.7/dist-packages\',\n \'/usr/lib64/python2.7/dist-packages/PIL\',\n \'/usr/lib/python2.7/dist-packages\']\n\n/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py in get_response\n response = self.process_exception_by_middleware(e, request) ...\n\n\xe2\x96\xb6 Local vars\n/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py in get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs) ...\n\xe2\x96\xb6 Local vars\n/usr/local/lib/python2.7/site-packages/django/views/decorators/cache.py in …Run Code Online (Sandbox Code Playgroud) 我试图在 Django 应用程序中设置 oauth2 身份验证。这是我的设置:
\n\n*other parts ommited*\n# AUTH STUFF\n\nAUTHENTICATION_BACKENDS = (\n \'social_core.backends.atlassian.AtlassianOAuth2\',\n \'django.contrib.auth.backends.ModelBackend\',\n)\n\nSOCIAL_AUTH_ATLASSIAN_KEY = \' *my atlassian key here* \'\nSOCIAL_AUTH_ATLASSIAN_KEY_SECRET = \' *my atlassian secret key here* \'\nLOGIN_URL = \'/auth/login/atlassian-oauth2\'\nLOGIN_REDIRECT_URL = \'/\'\nLOGOUT_REDIRECT_URL = \'/\'\nSOCIAL_AUTH_URL_NAMESPACE = \'social\'\n\nSESSION_COOKIE_SECURE = False\n# i had to do that^, based on what i have read from\n# /sf/ask/2633211591/\n# but it still doesn\'t work, sadly...\nRun Code Online (Sandbox Code Playgroud)\n\n这是我的登录页面视图:
\n\ndef index(request):\n session_id = request.session.session_key\n session_id = hashlib.sha256(str(session_id).encode(\'utf-8\')).hexdigest()\n auth_url = \'https://auth.atlassian.com/authorize?audience=api.atlassian.com&client_id=*my_client_id_here*&scope=read%3Ajira-user%20read%3Ajira-work%20manage%3Ajira-project&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fcomplete%2Fatlassian%2F&state=$\'+ session_id +\'&response_type=code&prompt=consent\'\n print(auth_url)\n context = {\n \'message\': …Run Code Online (Sandbox Code Playgroud) django oauth django-authentication jira-rest-api python-social-auth