azure-active-directory - 日历端点返回 OrganizationFromTenantGuidNotFound
问题描述
我目前正在尝试在 Node.js 中使用 Microsoft Graph 直接登录日历/用户。
到目前为止,我所做的如下:
登录该帐户并确保它当前有一个日历(电子邮件在 下注册
@outlook.com
)。转到 azure 门户并创建一个带有返回 URL 的新 AAD 名称“Calendar Api”Web API
http://localhost:3000
AAD -> 应用注册 -> 名称:测试,回复 url:localhost:3000,Microsoft Graph 所需的权限(用户读/写,日历读/写),Windows AAD(offline_access),授予权限,生成一个新的密钥没有到期日。
前往 Postman 并开始根据以下 URL 生成新令牌:
https://login.microsoftonline.com/{APP_ID_URI}.onmicrosoft.com/oauth2/v2.0/token
- 授予类型:
client_credentials
- client_id : {app_id}
- client_secret:{app_secret}
- 范围 :
https://graph.microsoft.com/.default
我200 OK
一个令牌。
- 检查令牌后:
"aud": "https://graph.microsoft.com",
"roles": [
"User.ReadWrite.All",
"Calendars.Read",
"Calendars.ReadWrite"
],
GET ON ->
https://graph.microsoft.com/v1.0/users/
with Authorization Bearer 和上面的令牌将返回代码状态 200 以及我在步骤 1 中使用的用户帐户。GET ON ->
https://graph.microsoft.com/v1.0/calendars/
with Authorization Bearer 和上面的令牌返回"Resource not found for the segment 'calendars'."
上车 ->
https://graph.microsoft.com/v1.0/users/{user_id}/calendars
或/calendar
或/calendarView
:
"code": "OrganizationFromTenantGuidNotFound",
"message": "The tenant for tenant guid '104fdcd9-76d1-4122-89a0-30cb00722de2' does not exist."
我真的没有代码,因为我首先使用 POSTMAN 测试 API。
我希望得到事件列表或日历列表,而不是错误。
解决方案
经过一番挖掘,我发现了问题所在,所以这里是这个问题的完整解决方案。
- 您需要一个订阅的 microsoft office 365 帐户,可以通过在 office 365 develop 上申请一个来获得。
- 创建一个后,按照说明将应用程序添加到其中。
- 转到 Azure 门户并使用您的 office 365 帐户登录。
- 在 AAD 下创建应用 -> 应用注册
- 按照此问题的第 4 步和第 5 步进行操作。
- 尝试访问 https://graph.microsoft.com/v1.0/users/{user_id}/calendars。
推荐阅读
- coq - 如何拆分两个列表的相等性?
- react-native - Windows 10 上的 React Native:npm install from mac 项目创建命令未找到问题
- sql - 捕获 null 的总和
- javascript - 签名板 ToDataURL 不适用于复杂签名
- flutter - Flutter 说 RenderFlex 子节点具有非零 flex 但传入的高度约束是无界的
- python - 查找包含在第一个括号内的子字符串
- amazon-web-services - 将 AWS Redis 缓存连接到多个 AWS 账户 Ec2 实例
- c - 如何从 python 中的 C 结构中获取值?
- kubernetes - 我在单节点 kubernetes 集群上面临“尝试回收临时存储”和磁盘压力“kubelet 有磁盘压力”
- powershell - 如何在 Powershell 中排除部分输出?