简体   繁体   English

Outlook API OAuth2使用php进行脱机访问/永久访问

[英]Outlook API OAuth2 offline acces / permanent access using php

I followed the tutorial below to get mail using outlook api. 我按照下面的教程使用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) 类似于gmail api的工作方式(当你不在键盘时访问)

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

Absolutely! 绝对! In order to get offline access, you need to add the offline_access scope to your requested scopes. 要进行脱机访问,您需要将offline_access范围添加到请求的范围。 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 . 请参阅https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-protocols/#oauth2-authorization-code-flow的“刷新访问令牌”部分。

Here is the actual string you would need to append to the scope: 以下是您需要附加到范围的实际字符串:

offline_access%20openid%20email%20profile

A basic example of a scope: 范围的基本示例:

"openid+https%3A%2F%2Foutlook.office.com%2Fmail.read+https%3A%2F%2Foutlook.office.com%2Fcalendars.read+offline_access%20openid%20email%20profile"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM