office365 - 从 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 中的权限设置吗?
解决方案
在我使用 JWT 工具查看我的访问令牌后,我发现该令牌没有“Office 365 Exchange Online”权限。
根本原因是,当我授权该应用使用我的 Office 365 帐户时,我没有为我的应用设置“Office 365 Exchange Online”权限。
即使我很快就编辑了权限设置,令牌仍然没有权限。
因此,修改权限设置后,我们应该重新认证并获得一个新的应用程序访问令牌。
推荐阅读
- docker - 无法共享 docker 构建之间的层
- python-3.x - 使用pyqt5单击按钮时如何调用该函数
- amazon-web-services - Amazon Forecast 的 create_dataset_import_job S3 角色需要星号访问 S3 资源
- c++ - HDF5 错误:无法锁定文件,资源暂时不可用
- javascript - Javascript - 不能在模块外使用 import 语句
- accessibility - 关闭模式视图后如何将焦点设置在以前的辅助功能元素上
- git - 如何将 SSH 私钥添加到 Intellij for Git
- java - Intellij 不允许我在项目目录中运行项目
- php - 无法从 woocommerce 中使用产品属性过滤的订单中获取变体属性
- laravel - 为什么我的下载功能(使用 Vue JS 和 Laravel 创建)会导致文件损坏?