python-social-auth / social-app-django

Python Social Auth - Application - Django
BSD 3-Clause "New" or "Revised" License
2.03k stars 380 forks source link

social auth redirects to login page after login (Google Oauth2) #75

Open vovkd opened 7 years ago

vovkd commented 7 years ago

For some reason social started redirect to login page even after authorization (user created, access code and refresh_token retrived). It worked perfectly and then just started redirect all new users back to login page, so they can't login

iamjagjeetubhi commented 7 years ago

Please help me, I have the same error. Everything was working before but now user redirects to login page again. here is my website https://thepoet.me I have created another app on facebook and it is working good on localhost.

deinokrates commented 6 years ago

Did anyone find a solution to this issue?

vovkd commented 6 years ago

For me problem was in another part of the system

tiffanyqi commented 6 years ago

Same issue. Any updates?

tiffanyqi commented 6 years ago

I've managed to pinpoint it to a Key Error for '_auth_user_id' in the get_user method in my virtualenv's django/contrib/auth/init.py from _get_user_session_key(request). Anyone know how to bypass the KeyError / not get an auth_user_id error? Thanks!

tiffanyqi commented 6 years ago

Fixed by changing is_active in my User model to default to True rather than False--thinking Django itself updated something

mattwilsoncp commented 6 years ago

I just went into /admin and deleted the user and then it started working again.

CiGuan commented 5 years ago

Did anyone find a solution to this issue?

sachitad commented 5 years ago

Hey guys, I recommend using django-allauth. Here is a quick tutorial to help you guys: https://www.youtube.com/watch?v=ZTBexYIIOP8

usudaysingh commented 4 years ago

Hi Guys, social-auth-login was working fine.But suddenly it does not. It redirects user to login page after all authentication and creation process user creation, retrieve tokens and save extra data on server. While it is working fine on local.And onserver gmail gives warning that website is insecure while on local it does not.

Can anyone please help...

usudaysingh commented 4 years ago

Fixed by changing is_active in my User model to default to True rather than False--thinking Django itself updated something

Hi tiffanyqi, i also tried this but not working.And other suggestion ?

chriscauley commented 4 years ago

TLDR; I had a typo in my AUTHENTICATION_BACKENDS.

I went through the login flow for google and it looked like nothing happened (worked great with github). I then loaded the session in the command line and it looked like the user was logged in. I eventually realized the session's authentication back end didn't match any of the entries in settings.AUTHENTICATION_BACKENDS, which means the session thought the user was logged in, but django was ignoring it. Fixing the typo fixed it.

vicentesuc commented 4 years ago

i solved this , doing the next.

First check your login {% url 'social:begin' 'google-oauth2' %}

remove if you have ?next={{ request.path }}

dont use at the same time

SOCIAL_AUTH_LOGIN_REDIRECT_URL='' LOGIN_REDIRECT_URL

just one of these..

add a path('/{your_url}')

i hope, this help to you