You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a django application that uses django social auth to authenticate users with Google. It was working just fine and then....suddenly it stopped. I have no clue why. I've tried everything I can think of.
Here's my social auth pipeline:
SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'myapp.custom_social_auth_pipeline.auth_allowed',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'myapp.custom_social_auth_pipeline.create_user', <--- also tried with social auth's create user function
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
)
And here's the code on my custom_social_auth_pipeline:
from django.contrib.auth.models import Group, User
from django.shortcuts import redirect
USER_FIELDS = ['username', 'email']
def create_user(strategy, details, backend, user=None, *args, **kwargs):
print("CREATE USER CALLED") <-- this is never called! :(
if user:
return {'is_new': False}
fields = dict((name, kwargs.get(name, details.get(name)))
for name in backend.setting('USER_FIELDS', USER_FIELDS))
try:
if User.objects.get(email=fields['email']):
return {'is_new': False, 'user': User.objects.get(email=fields['email'])}
except:
pass
if not fields:
return
fields['is_staff'] = True
user = strategy.create_user(**fields)
staff = Group.objects.get(name='Staff')
user.groups.add(staff)
return {
'is_new': True,
'user': user
}
def auth_allowed(backend, details, response, *args, **kwargs):
print ("AUTH ALLOWED CALLED") <-- this prints in my logs
print(details) <-- this returns the correct user
if not backend.auth_allowed(response, details):
return redirect('/')
It's not returning any error and it is not redirecting to our "error" url. It's just behaving like it does if no one is signed in (the app has a public-facing page that is for people who are not signed in, and if you try to go to another url, you get bounced back to that one). I feel like I must be missing something obvious, but I can't figure out what.
One other thing: it works perfectly on my local machine. On my server (AWS Lambda) it does not.
I'm just at a loss for what else to try, and would appreciate any guidance you can offer.
The text was updated successfully, but these errors were encountered:
I just wanted to drop an update here. I figured out that I had updated some things, and the issue was that social-auth-core had upgraded to 4.1.0. After I downgraded this to 3.3.3, the problem resolved.
I only was able to figure this out because my coworker was able to push a build from her computer that worked, and so we compared our pip-freeze output.
No clue why it worked locally but not on our staging instance (AWS Lambda deployed via Zappa). I'm just putting this here so others can find it.
0
I have a django application that uses django social auth to authenticate users with Google. It was working just fine and then....suddenly it stopped. I have no clue why. I've tried everything I can think of.
Here's my social auth pipeline:
And here's the code on my custom_social_auth_pipeline:
It's not returning any error and it is not redirecting to our "error" url. It's just behaving like it does if no one is signed in (the app has a public-facing page that is for people who are not signed in, and if you try to go to another url, you get bounced back to that one). I feel like I must be missing something obvious, but I can't figure out what.
One other thing: it works perfectly on my local machine. On my server (AWS Lambda) it does not.
I'm just at a loss for what else to try, and would appreciate any guidance you can offer.
The text was updated successfully, but these errors were encountered: