首页 > 解决方案 > 日历端点返回 OrganizationFromTenantGuidNotFound

问题描述

我目前正在尝试在 Node.js 中使用 Microsoft Graph 直接登录日历/用户。

到目前为止,我所做的如下:

  1. 登录该帐户并确保它当前有一个日历(电子邮件在 下注册@outlook.com)。

  2. 转到 azure 门户并创建一个带有返回 URL 的新 AAD 名称“Calendar Api”Web APIhttp://localhost:3000

  3. AAD -> 应用注册 -> 名称:测试,回复 url:localhost:3000,Microsoft Graph 所需的权限(用户读/写,日历读/写),Windows AAD(offline_access),授予权限,生成一个新的密钥没有到期日。

  4. 前往 Postman 并开始根据以下 URL 生成新令牌:

https://login.microsoftonline.com/{APP_ID_URI}.onmicrosoft.com/oauth2/v2.0/token

200 OK一个令牌。

  1. 检查令牌后:
"aud": "https://graph.microsoft.com",
    "roles": [
        "User.ReadWrite.All",
        "Calendars.Read",
        "Calendars.ReadWrite"
        ],
  1. GET ON -> https://graph.microsoft.com/v1.0/users/with Authorization Bearer 和上面的令牌将返回代码状态 200 以及我在步骤 1 中使用的用户帐户。

  2. GET ON -> https://graph.microsoft.com/v1.0/calendars/with Authorization Bearer 和上面的令牌返回"Resource not found for the segment 'calendars'."

  3. 上车 -> 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。

我希望得到事件列表或日历列表,而不是错误。

标签: azure-active-directorymicrosoft-graph-api

解决方案


经过一番挖掘,我发现了问题所在,所以这里是这个问题的完整解决方案。

  1. 您需要一个订阅的 microsoft office 365 帐户,可以通过在 office 365 develop 上申请一个来获得。
  2. 创建一个后,按照说明将应用程序添加到其中。
  3. 转到 Azure 门户并使用您的 office 365 帐户登录。
  4. 在 AAD 下创建应用 -> 应用注册
  5. 按照此问题的第 4 步和第 5 步进行操作。
  6. 尝试访问 https://graph.microsoft.com/v1.0/users/{user_id}/calendars

推荐阅读