如何在Microsoft图形API中获取用户日历事件

时间:2019-11-03 05:47:18

标签: azure-ad-graph-api

我已经在azure门户中为组织注册了一个应用程序。使用图谱api,我可以使用图谱api graph.microsoft.com/v1.0/users访问租户中存在的所有用户。

这是我用来获取单个用户日历的过程:

  1. graph.microsoft.com/v1.0/users。
  2. 复制用户的id/userPrincipalName
  3. graph.microsoft.com/v1.0/users/id/calendars/events。

在此过程中,我被禁止使用403。

请让我知道我的方法是否正确。

1 个答案:

答案 0 :(得分:0)

403表示您的Azure AD应用没有足够的权限来访问事件。

如果您使用的是Get access without a user,则需要在应用程序中添加Calendars.Read, Calendars.ReadWrite应用程序权限。

如果您使用的是Get access on behalf of a user,则需要向应用中添加Calendars.Read, Calendars.ReadWrite委派的权限。

List events Permissions中查看所需的权限。

有关如何添加API权限,请参阅Manage API permission


更新

获取应用程序权限:日历。请阅读作为示例。

在Azure AD应用程序中添加权限后,请不要忘记单击底部的“授予***的管理员许可”按钮。 enter image description here

然后使用Get access without a user获取访问令牌。 enter image description here

获取访问令牌后,调用日历事件端点。 enter image description here

“授权”值的格式为“承载者{从最后一步进入access_token}”。


更新2: enter image description here