Graph getting events of another user

Ruslan 0 Reputation points
2023-03-23T18:24:08.4633333+00:00

I try go get events of another users. But I can not do it. I get result only for current user.

error:

Status Code: Forbidden

Microsoft.Graph.ServiceException: Code: ErrorAccessDenied
Message: Access is denied. Check credentials and try again.
ClientRequestId: d1903ca9-1a96-4704-bc9c-35c01f557bf1
var events = await Graph.Users[email].Calendars[calendarId].Events.Request().GetAsync();

Here permissions: User's image

What is wrong?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,301 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Siddharth Gautam 855 Reputation points
    2023-03-23T20:36:48.1166667+00:00

    Hello Ruslan,

    Thanks for reaching out.

    You can decode your access token in jwt.ms to ensure that the token contains the correct set of permissions.

    In case if you are using a Delegated permissions with users/{user-id}/calendars/{calendar-id}/events, then that will also return the above error.

    You can test below Graph Endpoint in API Client like Postman with a token generated using Client Credential flow having required permissions in AAD application.

    users/{user-id}/calendars/{calendar-id}/events

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.