Skip to content Skip to sidebar Skip to footer

Session Value Missing After Redirect With Django Python-social-auth

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 applicati

Solution 1:

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

Solution 2:

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

Solution 3:

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

Solution 4:

In my case, this had to do with v96-era browsers changing the default for SameSite cookies from "None"/"–" to "Lax" and this at least affects multisite authentication on HTTP like localhost (maybe not HTTPS). Old django 2.1 does not let you specify these to be "None", so it stopped working.

For now in Safari 15.2, the old cookies still work.

Post a Comment for "Session Value Missing After Redirect With Django Python-social-auth"