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

使用O365 auth_flow_type='credentials'时遇'messages'资源未找到错误

问题:切换凭证认证后提示“Resource not found for the segment 'messages'”

为跳过登录流程,我将代码中的认证类型从authorization改为credentials,但始终收到错误提示:Resource not found for the segment 'messages'。我尝试调整Azure权限设置,但没有解决问题。

代码示例

import sys
import os

from O365 import Account,FileSystemTokenBackend

credentials = ('3c7adf9b-3126-45d9-8239-3a9a66dbaae3','J8Q8Q~--------------------------')

token_backend = FileSystemTokenBackend(token_path=os.getcwd()+'/token_folder/', token_filename='my_token.txt')
account = Account(credentials, auth_flow_type='credentials', tenant_id='f3aaaf31-b8db-4e24-b8a3-----------',token_backend=token_backend)
if account.authenticate():
    print('Authenticated!')

    mailbox = account.mailbox(resource = 'wo----------------hotmail.onmicrosoft.com')

    messages = mailbox.get_messages(limit=1500)  

    for message in messages:
        print(message.subject)

输出截图

输出错误截图

Azure设置截图

  1. Azure配置截图1
  2. Azure配置截图2
  3. Azure配置截图3

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 21:06:17