我正在使用 this architecture 创建 Outlook 加载项.
我正在尝试处理 Azure Active Directory 访问 token 过期的情况。根据the official documentation , token 的生命周期为1小时。
因此,我正在考虑更改 token 的生命周期,如 this question 中所述。 。但我不能这样做,因为我无权编辑 Azure 策略。另外,我相信有一种更干净的方法来测试这种情况。
如何测试/调试这个场景?
最佳答案
每当您的访问 token 过期时,您都可以使用刷新 token 来交换新的访问/刷新 token 对。刷新 token 的最长不活动时间为 90 天。 通过在发出请求时在范围参数中指定offline_access,您可以在请求访问 token 时在结果中获取刷新 token 。
curl --location --request POST 'https://login.microsoftonline.com/common/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id={clientid}' \
--data-urlencode 'refresh_token={refreshtoken}' \
--data-urlencode 'redirect_uri={redirect_uri}' \
--data-urlencode 'grant_type=refresh_token' \
--data-urlencode 'client_secret={client_secret}'
关于azure - 如何测试 Azure AD 访问 token 过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48755981/