在base64解码我的承载令牌后,我注意到它的寿命只有1H,文档也说是一样的,1H。
我希望使用寿命至少为2-3个月,但在微软的api中,我看不到这样的选项,它只写
此请求需要以下格式的URL编码有效载荷:
grant_type=授权代码
&redirect_uri=uri
&client_id=id
&client_secret=secret_key
&code=代码
&resource=https%3A%2F%2Graph.microsoft.com/%2F
任何人都可以帮我弄清楚我应该在POST请求中传递哪些其他参数。
token_url = '{0}{1}'.format(self.AUTHORITY, '/common/oauth2/token')
post_data = {
'grant_type': 'authorization_code',
'code': auth_code,
'redirect_uri': redirect_uri,
'resource': 'https://graph.microsoft.com',
'client_id': self._client_id,
'client_secret': self._client_secret
}
request = requests.post(token_url, data = post_data)
return request.json()
提前感谢
没有延长寿命的选项。但是,您还应该收到一个刷新令牌,您可以使用该令牌来请求新令牌,而无需用户交互。