使用OAUTH2连接到Outlook Office 365 IMAP [英] Connect to outlook Office 365 IMAP using OAUTH2

查看:242
本文介绍了使用OAUTH2连接到Outlook Office 365 IMAP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已引用 https://msdn. microsoft.com/en-us/office/office365/api/use-outlook-rest-api . 仍然我无法理解AD,Outlook和Windows Live.

我从 https://login.microsoftonline获得刷新令牌和访问令牌.com/common/oauth2/v2.0/authorize https://login.microsoftonline.com/common/oauth2/v2.0/令牌

和范围

openid电子邮件配置文件offline_access https://outlook.office.com/mail.send https://outlook.office.com/mail.readwrite

使用访问令牌连接imap时仍然出现错误.

imap.authenticate('XOAUTH2', 'xxxxxxx', access_token)
Net::IMAP::NoResponseError: AUTHENTICATE failed.

解决方案

对于那些询问有关个人帐户的IMAP的人-Outlook.com
-重新:评论

显然,消费者Outlook.com(也为live.com)的范围为wl.imap.
请参见范围和权限.

也请看以下示例,其中提到了相同的作用域:
http://afterlogic.com/mailbee-net/docs/OAuth2MicrosoftRegularAccountsInstalledApps.html

顺便说一句,我们遇到了 Clever Components 文章中的旧Microsoft文档:

https://www.clevercomponents.com/articles/article049/

  • 注意:他们声称这是针对Office365的,这可能是有问题的,也许是因为文档方面的错误

具有指向Microsoft文档的链接:

https://msdn.microsoft.com/en-us/windows /desktop/dn440163

在页面末尾列出的相关部分中具有指向Scopes and permissions的链接:

https://msdn.microsoft.com/en-us/windows /desktop/hh243646

聪明的组件文章中,他们使用了两个范围wl.imapwl.offline_access.
他们指出:

Microsoft建议将"wl.offline_access"作用域与"wl.imap"一起使用.否则,只有当用户登录Live Connect并使用您的应用程序时,该应用程序才能访问该用户的信息."

因此,如果您的应用程序需要连续访问,则需要包括脱机访问范围.

Referred https://msdn.microsoft.com/en-us/office/office365/api/use-outlook-rest-api. Still I couldn't understand the AD, Outlook and windows live.

I got refresh token and access token from https://login.microsoftonline.com/common/oauth2/v2.0/authorize https://login.microsoftonline.com/common/oauth2/v2.0/token

and the scope

openid email profile offline_access https://outlook.office.com/mail.send https://outlook.office.com/mail.readwrite

Still i m getting error while connect imap using the access token.

imap.authenticate('XOAUTH2', 'xxxxxxx', access_token)
Net::IMAP::NoResponseError: AUTHENTICATE failed.

解决方案

For those asking about IMAP for personal accounts -- Outlook.com
-- re: comment

Apparently the scopes for the consumer Outlook.com (also live.com) is wl.imap.
See old Microsoft doc on Scopes and permissions.

Also have a look at this example where the same scope is mentioned:
http://afterlogic.com/mailbee-net/docs/OAuth2MicrosoftRegularAccountsInstalledApps.html

BTW, we came across the old Microsoft doc from Clever Components article:

https://www.clevercomponents.com/articles/article049/

  • note: their claim this is for Office365 may be questionable, perhaps a documentation error on their part

which has a link to a Microsoft doc:

https://msdn.microsoft.com/en-us/windows/desktop/dn440163

which has a link to Scopes and permissions in the related section listed at the end of the page:

https://msdn.microsoft.com/en-us/windows/desktop/hh243646

In the Clever Components article, they used two scopes wl.imap and wl.offline_access.
They noted that:

Microsoft recommends to use the "wl.offline_access" scope together with "wl.imap". Otherwise, an app can access the user's info only when a user signs in to Live Connect and uses your app."

So if your application needs continuous access then you need to include the offline access scope.

这篇关于使用OAUTH2连接到Outlook Office 365 IMAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆