Search code examples
djangodjango-allauth

How to set password in user table when user is signup using google or facebook django allauth


By overriding the SocialAccountManager

def save_user(self, request, sociallogin, form=None):
    """
    Saves a newly signed up social login. In case of auto-signup,
    the signup form is not available.
    """
    u = sociallogin.user
    u.set_unusable_password()
    if form:
        get_account_adapter().save_user(request, u, form)
    else:
        get_account_adapter().populate_username(request, u)
    sociallogin.save(request)
    return u

how to get the password from social account signup


Solution

  • Actually, you can't.

    Django Allauth does not hash or store passwords for social login users. It does not handle the authentication on its end.

    Suppose a user try to do a google login at your website, the authentication happens on google servers not on your end. If the user's password is correct then LOGIN_REDIRECT_URL = "url-name/" defined in your django project redirects that user to the url.