Session value missing after redirect with django python-social-auth

前端 未结 3 547
一整个雨季
一整个雨季 2020-12-19 18:00

I am working on a django project using python-social-auth to do authentication with facebook. I am running the django server on localhost and have facebook set up with my ap

相关标签:
3条回答
  • 2020-12-19 18:45

    This error was due to the session cookie not being saved over a non-https url. When testing on localhost with SESSION_COOKIE_SECURE set to True in django, the session cookies will not persist between redirect and you will get this error in any kind of page change where session would be checked.

    SESSION_COOKIE_SECURE=False for testing and it's all good

    0 讨论(0)
  • 2020-12-19 18:47

    Solved it by removing LOGIN_REDIRECT_URL from django settings.

    Actually python_social_auth pipeline structure sets LOGIN_REDIRECT_URL as next i.e redirect to url, but unfortunately they didn't handled named patterns. So, when we set LOGIN_REDIRECT_URL to myapp:index it produces this error.

    So, either remove this setting or use direct patterns i.e

    LOGIN_REDIRECT_URL = myapp/index

    0 讨论(0)
  • 2020-12-19 18:48

    I also had this problem. Solved it by adding "SOCIAL_AUTH_REDIRECT_IS_HTTPS = True" in my settings.py file, since my configuration is using nginx to redirect to HTTPS. I found this answer only by reading the documentation here: https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html

    0 讨论(0)
提交回复
热议问题