This page is still under construction.

back to posts

Django Allauth - get user tokens

06/30/2020

https://github.com/pennersr/django-allauth/issues/122

Sep 25, 2015 Users can connect multiple social accounts to their user account, so there may be multiple tokens in the system.

Here is how to list all Facebook tokens, given a user:

from allauth.socialaccount.models import SocialToken
SocialToken.objects.filter(account__user=user, account__provider='facebook')

Note that allauth only stores the tokens. How they are accessed and used is project dependent and therefore beyond allauth scope.

If you found it useful, please consider signing up to my newsletter. Every week, I share my thoughts on cool stuff I found around the internet. No spam, ever. Unsubscribe any time.