Microsoft Graph API: How to access guest user calendar events using API?

Sanket Khot 51 Reputation points
2023-01-13T04:16:37.7633333+00:00

Hi,

I am working on an outlook calendar integration with our application. I have got a business/organisation Microsoft account.

So far I have registered an application in the Azure active directory admin centre.
I have added API Following API permissions

User's image

Then I used the following API call to get the access token

https://login.microsoftonline.com/{Tenant_ID}/oauth2/v2.0/token

I received a Bearer token and used it for following API call

https://graph.microsoft.com/v1.0/users

I am getting list of users and one of then is guest user. Now I want to get calendar events of this guest user and I am using following API call

https://graph.microsoft.com/v1.0/users/{user_id}/calendars
https://graph.microsoft.com/v1.0/users/{user_id}/calendars/events
https://graph.microsoft.com/v1.0/users/{user_id}/events

I am getting following error only for guest users but I am getting right data for Member users.

AadGuestPft token doesn't contain the permissions required by the target API.

Any Idea what is going on here?

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

Accepted answer
  1. CarlZhao-MSFT 36,736 Reputation points
    2023-01-13T10:01:11.1233333+00:00

    Hi @Sanket Khot

    Guest users don't have Exchange mailboxes in your enterprise tenant, so you can't list calendar events for guest users in your tenant, you can only get calendar events in the original tenant where the guest user is located.

    Change /{tenant id} to /common, and then log in with your guest user to get a delegation token.

    Call the graph API:

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


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


1 additional answer

Sort by: Most helpful
  1. Vasil Michev 94,836 Reputation points MVP
    2023-01-13T07:49:10.1466667+00:00

    Guests do not have a mailbox within the resource tenant, so you cannot query Calendar data for them.

    0 comments No comments