Have multiple accpunts on the same provider in python-social-auth

I am currently using python-social-auth package for authenthication in my django site. I want users to be able to associate multiple social accounts to on django account. But if I call social:begin view when user is already logged in with account from the same provider, it does nothing and just logs in the old account. Is there a way to tell it to force adding of new account from that provider?

Thanks.

Upvotes: 1

Views: 393

Answers (1)

omab
omab

Reputation: 3701

You need to tell the provider that you want to show the user the "select account" form again (when possible, since this is provider dependent), or ask the user to logout from the original account if it wants to add another association.

For example, with google-oauth2 you can do it by adding this setting

SOCIAL_AUTH_GOOGLE_OAUTH2_AUTH_EXTRA_ARGUMENTS = {
    'prompt': 'select_account'
}

Google's API documentation lists the supported values for prompt.

You can also play with this other option:

SOCIAL_AUTH_GOOGLE_OAUTH2_AUTH_EXTRA_ARGUMENTS = {
    'approval_prompt': 'force'
}

Upvotes: 1

Related Questions