Reputation: 21
I have registered an app in the azure portal for an organization. With the graph api I am able to access all users present in the tenant using graph api graph.microsoft.com/v1.0/users
.
This is the process that I am using to get an individual user's calendar:
id/userPrincipalName
of a user. In this process I am getting 403 forbidden.
Please let me know if my approach is correct or not.
Upvotes: 2
Views: 14823
Reputation: 16438
403 means that your Azure AD app doesn't have enough permissions to access the events.
If you are using Get access without a user, you need add Calendars.Read, Calendars.ReadWrite
Application permissions into your app.
If you are using Get access on behalf of a user, you need to add Calendars.Read, Calendars.ReadWrite
Delegated permissions into your app.
See the required permissions from List events Permissions.
For how to add API permissions, you could refer to Manage API permission.
Update
Take Application permission: Calendars.Read as an example.
After you add the permission in Azure AD app, don't forget to click on the "Grant admin consent for ***" button at the bottom.
And then use Get access without a user to get the access token.
After getting the access token, call the calendar events endpoint.
The format of the value of Authorization is "Bearer {access_token from the last step}".
Upvotes: 5