Outlook API OAuth2 离线访问/使用 php 永久访问

我按照下面的教程使用 Outlook api 获取邮件.这有效,但需要用户每次登录以授予访问权限.有没有办法提供永久/离线访问?类似于 gmail api 的工作方式(当您不在键盘上时访问)

I followed the tutorial below to get mail using outlook api. This works, but requires the user to login every time to give access. Is there a way to give permanent / offline access? Similar to how gmail api works (access to when your not at your keyboard)

https://dev.outlook.com/RestGettingStarted/Tutorial/php

推荐答案

当然可以!为了获得离线访问,您需要将 offline_access 范围添加到您请求的范围中.这将导致刷新令牌与您的访问令牌一起发送.您可以使用刷新令牌在当前令牌过期时获取新的访问令牌.请参阅 https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-protocols/#oauth2-authorization-code-flow.

Absolutely! In order to get offline access, you need to add the offline_access scope to your requested scopes. This will result in a refresh token being sent along with your access token. You can use the refresh token to get a new access token when the current one expires. See the "Refresh the Access Token" section of https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-protocols/#oauth2-authorization-code-flow.

相关文章