social-app-django icon indicating copy to clipboard operation
social-app-django copied to clipboard

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

Open vovkd opened this issue 8 years ago • 13 comments

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

vovkd avatar Aug 08 '17 07:08 vovkd

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.

iamjagjeetubhi avatar Aug 24 '17 16:08 iamjagjeetubhi

Did anyone find a solution to this issue?

deinokrates avatar Nov 08 '17 11:11 deinokrates

For me problem was in another part of the system

vovkd avatar Nov 08 '17 13:11 vovkd

Same issue. Any updates?

tiffanyqi avatar Nov 10 '17 06:11 tiffanyqi

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 avatar Nov 10 '17 07:11 tiffanyqi

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

tiffanyqi avatar Nov 16 '17 01:11 tiffanyqi

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

mattwilsoncp avatar Feb 10 '18 19:02 mattwilsoncp

Did anyone find a solution to this issue?

CiGuan avatar Nov 11 '18 20:11 CiGuan

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

sachitad avatar Feb 06 '19 10:02 sachitad

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 avatar Nov 09 '19 22:11 usudaysingh

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 ?

usudaysingh avatar Nov 09 '19 22:11 usudaysingh

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.

chriscauley avatar May 28 '20 15:05 chriscauley

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

vicentesuc avatar Jun 18 '20 16:06 vicentesuc