[Answer]-Cannot import python social auth into Django app that uses custom login

1👍

You should use the pipeline feature in python-social-auth to setup that token, for example (pseudo code):

def set_token(user, is_new=False, *args, **kwargs):
    profile = get_or_create_profile(user)
    profile.token = "new token"
    profile.save()

Let’s say you put that function in a file at project/apps/app1/pipeline.py, then add this entry to your settings:

SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.user.get_username',
    'social.pipeline.user.create_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details'
    'apps.app1.pipeline.set_token'
)
👤omab

Leave a comment