Microsoft Graph - 获取访问令牌

Microsoft Graph - Get Access Token

我想创建一个后端 Node.js 应用程序以管理 Outlook 日历(创建、删除、更新事件...)。但是我想每次都更新同一个日历(总是同一个帐户)。面向所有人的全球日历。

真正的目的是将此日历后端与 dialogFlow 功能集成(类似于 Google 日历 https://github.com/dialogflow/fulfillment-bike-shop-nodejs 中的示例)

我一直在寻找 https://docs.microsoft.com/en-us/graph/auth-v2-service,但我不知道这样做是否正确。

我在 Azure 门户中创建了一个应用程序,并获得了我的令牌:

POST https://login.microsoftonline.com/{租户}/oauth2/v2.0/令牌HTTP/1.1

但无法访问 https://graph.microsoft.com/v1.0/users/{id}/calendars。我收到的消息与此类似:

"code": "OrganizationFromTenantGuidNotFound",
"message": "The tenant for tenant guid '68cc4dcb-5873-4ea0-a498-fe57e9b5d827' does not exist."

I've been looking to https://docs.microsoft.com/en-us/graph/auth-v2-service, but I don't know if it is the correct aproach to do it.

我觉得这个可行

"code": "OrganizationFromTenantGuidNotFound",

您需要使用用户(tonyju@abc.onmicrosoft.com) 访问日历。而且这个账号必须已经分配了O365 license 可以参考.

更新:

如果您只想访问个人帐户的日历,可以使用auth code flow 获取访问令牌。然后使用

https://graph.microsoft.com/v1.0/me/calendars