日历端点返回 OrganizationFromTenantGuidNotFound

And*_*ica 2 azure-active-directory microsoft-graph-api

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

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

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

  2. 转到azure门户并创建一个新的AAD名称“Calendar Api”带有返回URL的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
Run Code Online (Sandbox Code Playgroud)
  • 授予类型:client_credentials
  • 客户端 ID:{app_id}
  • 客户端秘密:{应用程序秘密}
  • 范围 :https://graph.microsoft.com/.default

我有200 OK一个令牌。

  1. 检查令牌后:
"aud": "https://graph.microsoft.com",
    "roles": [
        "User.ReadWrite.All",
        "Calendars.Read",
        "Calendars.ReadWrite"
        ],
Run Code Online (Sandbox Code Playgroud)
  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/使用 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."
Run Code Online (Sandbox Code Playgroud)

我实际上没有代码,因为我首先使用 POSTMAN 来测试 API。

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

And*_*ica 5

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

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