相关疑难解决方法(0)

用于 IMAP 和 SMTP 身份验证的 Office 365 XOAUTH2 失败

最近宣布支持 Exchange Online 中的 IMAP 和 SMTP 的 OAuth 2.0。按照指南,我设置了应用程序权限以及 IMAP 和 SMTP 连接。应用程序配置为Accounts in any organizational directory (Any Azure AD directory - Multitenant)并使用授权代码流

以下 URL 用于授权:

并且添加了以下委派 Microsoft Graph 范围:

在此处输入图片说明

范围,来自代码的请求:

final List<String> scopes = Arrays.asList(
    "offline_access",
    "email",
    "openid",
    "profile",
    "User.Read",
    "Mail.ReadWrite",
    "https%3A%2F%2Foutlook.office365.com%2FIMAP.AccessAsUser.All",
    "https%3A%2F%2Foutlook.office365.com%2FSMTP.Send"
);
Run Code Online (Sandbox Code Playgroud)

我成功收到访问和刷新令牌:

{
    "token_type": "Bearer",
    "scope": "email IMAP.AccessAsUser.All Mail.ReadWrite openid profile SMTP.Send User.Read",
    "expires_in": 3599,
    "ext_expires_in": 3599,
    "access_token": "edited",
    "refresh_token": "edited",
    "id_token": "edited"
}
Run Code Online (Sandbox Code Playgroud)

这是用于连接到 …

java imap smtp oauth-2.0 office365

6
推荐指数
1
解决办法
6745
查看次数

标签 统计

imap ×1

java ×1

oauth-2.0 ×1

office365 ×1

smtp ×1