Identification of the backend provider of the registered user

With django-social-auth, is there a good way to find out which backend provider has registered a user? Is finding the appropriate UserSocialAuth object the best way?

Thank!

0
source share
2 answers

In your views try:

request.user.social_auth.values_list('provider')

to get a list of connections connected to the user.

+2
source

The last login is stored in the session using the social_auth_last_login_backenddefault key , otherwise yes, checking the instances UserSocialAuthis the preferred way by doing user.social_auth.filter().

Both methods can be combined by doing:

user.social_auth.filter(provider=request.session['social_auth_last_login_backend'])
+3
source

All Articles