You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

有效Access Token下IMAP OAuth2登录失败排查求助

关于Office365 IMAP OAuth2认证失败的问题

我基于OAuth2 IMAP/SMTP实现的代码进行开发,获取到的令牌在Microsoft Graph API中能正常使用,但用它进行Office365 IMAP服务器认证时失败,报错信息如下:

Traceback (most recent call last):
  File "/Users/uttam/Documents/work/fast-api/imap_synching/.env/lib/python3.10/site-packages/imapclient/imapclient.py", line 415, in oauth2_login
    return self._command_and_check("authenticate", mech, lambda x: auth_string)
  File "/Users/uttam/Documents/work/fast-api/imap_synching/.env/lib/python3.10/site-packages/imapclient/imapclient.py", line 1738, in _command_and_check
    typ, data = meth(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/imaplib.py", line 444, in authenticate
    raise self.error(dat[-1].decode('utf-8', 'replace'))
imaplib.IMAP4.error: AUTHENTICATE failed.

我尝试用以下命令手动测试认证:

openssl s_client -showcerts -connect outlook.office365.com:993 -servername outlook.office365.com -crlf

但发现这个命令最多仅支持1024个字符,而我获取的令牌长度在4k-5k字符左右。不确定是令牌长度导致IMAP认证失败,还是存在其他问题,恳请各位提供技术帮助。

内容的提问来源于stack exchange,提问作者Lekhnath Parajuli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 02:25:25