如何在Microsoft graph api中获取用户日历事件

问题描述 投票:0回答:2

我已经在组织的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。

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

azure-ad-graph-api
2个回答
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


更新

以应用程序权限:Calendars.Read为例。

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

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

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

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


© www.soinside.com 2019 - 2024. All rights reserved.