我在我的网站上实现了 Python Social Auth,我正在尝试(在登录过程之后)访问用户获得的访问令牌。我可以在 Django 管理员上看到一个名为 extra_data 的字段,其中包含访问令牌,但我不知道如何从我的代码中访问它。
任何想法?
我想做一些类似的事情,因为它可以在 Django Social Auth 中完成:http: //django-social-auth.readthedocs.org/en/latest/tokens.html
我在我的网站上实现了 Python Social Auth,我正在尝试(在登录过程之后)访问用户获得的访问令牌。我可以在 Django 管理员上看到一个名为 extra_data 的字段,其中包含访问令牌,但我不知道如何从我的代码中访问它。
任何想法?
我想做一些类似的事情,因为它可以在 Django Social Auth 中完成:http: //django-social-auth.readthedocs.org/en/latest/tokens.html
给定一个用户实例,您可以通过以下方式获取令牌:
social = user.social_auth.get(provider='provider name')
social.extra_data['access_token']
假设 Facebook 提供商:
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']}
)