[Solved]-Get access token from Python Social Auth

36👍

Given a user instance, you can get the token by doing this:

social = user.social_auth.get(provider='provider name')
social.extra_data['access_token']

Assuming Facebook provider:

social = user.social_auth.get(provider='facebook')
social.extra_data['access_token']
👤omab

2👍

http://python-social-auth.readthedocs.org/en/latest/use_cases.html#retrieve-google-friends

user = User.objects.get(...)
social = user.social_auth.get(provider='google-oauth2')
response = requests.get(
    'https://www.googleapis.com/plus/v1/people/me/people/visible',
    params={'access_token': social.extra_data['access_token']}
)

Leave a comment