我使用Python Social Auth - Django登录我的用户.
我的后端是微软,所以我可以使用Microsoft Graph,但我不认为它是相关的.
Python Social Auth处理身份验证,但现在我想调用API,为此,我需要一个有效的访问令牌.根据用例我可以得到:
social = request.user.social_auth.get(provider='azuread-oauth2')
response = self.get_json('https://graph.microsoft.com/v1.0/me',
headers={'Authorization': social.extra_data['token_type'] + ' '
+ social.extra_data['access_token']})
Run Code Online (Sandbox Code Playgroud)
但访问令牌只有3600秒有效,所以我需要刷新,我想我可以手动完成,但必须有一个更好的解决方案.如何刷新access_token?