I have Python Social Auth implemented on my site, and I'm trying to access (after the login process) into the access token that the user got. I can see on the Django admin that there's a field called extra_data containing the access token, but I don't know how to access it from my code.
Any idea?
I want to do something similar as it could be done in Django Social Auth: http://django-social-auth.readthedocs.org/en/latest/tokens.html
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']
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']}
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.