[Answer]-Django Social Auth Partial Pipeline: AuthTokenError

1๐Ÿ‘

You should put your pipeline entry after the user is created and the social account is associated (after social_auth.backends.pipeline.social.associate_user entry), then you can try with this code:

def gather_extra_data(social_auth, user, details, request, is_new=False, *args, **kwargs):
    if is_new:
        if request.session.get('saved_email') is None:
            return redirect(request_extra, backend=backend.name)
        else:
            details['email'] = request.session['saved_email']
            details['password'] = request.session['password']
            details['first_name'] = request.session['first_name']
            details['last_name'] = request.session['last_name']
            details['dob'] = request.session['dob']
            details['gender'] = request.session['gender']
            details['avatar_url'] = request.session['avatar_url']

Remember to put social_auth.backends.pipeline.misc.save_status_to_session before your entry.

๐Ÿ‘คomab

0๐Ÿ‘

Try this way:

def gather_extra_data(backend, details, uid, request, user=None, is_new=False, *args, **kwargs):

If not user is None and is_new: #is_new is your missing argument.
    if not details.get('email'):
        if not request.session.get('saved_email'):
            return redirect(request_extra, backend=backend.name)
        else:
            details['email'] = request.session['saved_email']
            details['password'] = request.session['password']
            details['first_name'] = request.session['first_name']
            details['last_name'] = request.session['last_name']
            details['dob'] = request.session['dob']
            details['gender'] = request.session['gender']
            details['avatar_url'] = request.session['avatar_url']
๐Ÿ‘คPiotr Kowalczuk

Leave a comment