首页 > 解决方案 > 从 Microsoft Exchange Server 接收 invalid_grant

问题描述

我在将 api 发送到 Exchange Server 时遇到问题。我在 Azure 中注册了一个应用,并将“Office 365 Exchange Online”权限添加到 api 访问角色中。

接下来,我按照这个文档获取了一个仅限应用程序的访问令牌,然后发送 GetItem EWS api 来获取邮件,但服务器响应错误 401 Unauthorized。

x-ms-diagnostics: 2000008;"reason"=The token contains no permissions, or permissions can not be understood.";error_category="invalid_grant"

我必须设置 Office 365 中的权限设置吗?

标签: office365exchange-serverexchange-server-2007

解决方案


在我使用 JWT 工具查看我的访问令牌后,我发现该令牌没有“Office 365 Exchange Online”权限。

根本原因是,当我授权该应用使用我的 Office 365 帐户时,我没有为我的应用设置“Office 365 Exchange Online”权限。

即使我很快就编辑了权限设置,令牌仍然没有权限。

因此,修改权限设置后,我们应该重新认证并获得一个新的应用程序访问令牌。


推荐阅读