Django social-auth unified account association

I am using django social-auth ( http://django-social-auth.readthedocs.org/en/latest/index.html ) and trying to create a user profile in which a user can link multiple accounts (e.g. here on Stackoverflow )

I am currently in a place where one user can log in using different authentication providers, but a new user is created for each login. How can I link all user accounts to one (for example, a user profile)?

Also, what is best for creating a user profile page when using django social-auth?

+5
source share
2 answers

DSA already supports multiple account associations, the trick is that the user must log in, otherwise the DSA does not know that it must be associated with an existing account.

As for your profile, the recommended way to add functionality to DSA is to expand the pipeline , you can create an entry similar to this:

def create_profile(user, is_new=False, *args, **kwargs):
    if is_new:
        # create a profile instance for the given user
        create_user_profile(user)

Then register it in the following settings:

SOCIAL_AUTH_PIPELINE = (
    'social_auth.backends.pipeline.social.social_auth_user',
    'social_auth.backends.pipeline.user.get_username',
    'social_auth.backends.pipeline.user.create_user',
    'social_auth.backends.pipeline.social.associate_user',
    'social_auth.backends.pipeline.social.load_extra_data',
    'social_auth.backends.pipeline.user.update_user_details',
    'myapp.pipeline.create_profile'
)

If the record is the import path to get this function.

Edit: link to documents and setting explanations.

+9
source

I see 2 alternative when you want to handle multiple account associations:

    • Find the unique attribute that all identity providers have.
    1. .

2

  • , , . , , , , , Twitter .

  • . , .

. (ldap, , ). , " X ", , .

. , , . ( somethig " )

, - , .

django. djago social-auth apps. django-socialprofile

+1

All Articles