首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >连接到Exchange服务时出现无效凭据错误

连接到Exchange服务时出现无效凭据错误
EN

Stack Overflow用户
提问于 2020-12-18 11:46:23
回答 1查看 3.2K关注 0票数 1

我正在尝试连接到Exchangelib服务,以获得对Outlook的访问,并使用Python中的Exchangelib库对数据进行分组。我遵循下面的文章,https://github.com/ecederstrand/exchangelib/issues/747

下面是代码片段,

代码语言:javascript
复制
from exchangelib import IMPERSONATION, Account, Credentials, OAuth2Credentials, \
    Configuration, OAUTH2, Identity

client_id='XXX'
client_secret='XXX'
tenant_id='XXX'
user= 'XXX@YYY.onmicrosoft.com'

credentials = OAuth2Credentials(
    client_id=client_id,
    client_secret=client_secret,
    tenant_id=tenant_id,
    identity=Identity(primary_smtp_address=user)
)
config = Configuration(
    credentials=credentials,
    auth_type=OAUTH2,
    service_endpoint="https://outlook.office365.com/EWS/Exchange.asmx",
)
account = Account(
    user,
    config=config,
    autodiscover=False,
    access_type=IMPERSONATION,
)
print(account.root.all().count())

我已经正确地给出了所有的凭据,但是我得到了一个无效的凭据错误,如下所示.

代码语言:javascript
复制
    886     if response.status_code == 401 and protocol.retry_policy.fail_fast:
    887         # This is a login failure
--> 888         raise UnauthorizedError('Invalid credentials for %s' % response.url)
    889     if 'TimeoutException' in response.headers:
    890         raise response.headers['TimeoutException']

UnauthorizedError: Invalid credentials for https://outlook.office365.com/EWS/Exchange.asmx

任何解决方案都将不胜感激。提前谢谢。

EN

Stack Overflow用户

发布于 2022-07-01 08:27:26

有相同的问题,就像上面所描述的,并且我得到了自动发现:ErrorNonExistentMailbox: The SMTP address has no mailbox associated with it,但是如果您不使用模拟,这似乎是预期的。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65356490

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档