I create a calendar, I delegate it to other users, I have a Laravel development but when the delegated user accesses the calendar it shows another calendar ID, I don't understand why this happens

Gustavo Adolfo Contreras Salas 0 Reputation points
2023-09-25T16:00:37.51+00:00
I create a calendar, I delegate it to other users, I have a Laravel development but when the delegated user accesses the calendar it shows another calendar ID, I don't understand why this happens
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Carolyne-3676 881 Reputation points
    2023-10-05T07:46:46.4766667+00:00

    It's possible that the delegated user is accessing a different calendar than the one you intended to delegate. To verify this, you can retrieve the calendar ID of the delegated user's calendar using Microsoft Graph API and compare it with the calendar ID you intended to delegate.

    Here is a sample code snippet in PHP using Microsoft Graph API to get the ID of a user's calendar:

    $userPrincipalName = "<User's email address>";
    $calendarView = $graph->createRequest("GET", "/users/$userPrincipalName/calendarView")
        ->setReturnType(Model\Event::class)
        ->execute();
    
    $calendarId = $calendarView->getCalendarId();
    echo "Calendar ID: " . $calendarId;
    

    If the calendar ID retrieved using the above code does not match the one you intended to delegate, it's possible that you may have delegated the wrong calendar or the delegated user may have multiple calendars. You can try to retrieve a list of all calendars for the delegated user using the calendars endpoint.
    This will return a list of all calendars for the delegated user, and you can compare the IDs with the one you intended to delegate.

    $calendars = $graph->createRequest("GET", "/users/$userPrincipalName/calendars")
        ->setReturnType(Model\Calendar::class)
        ->execute();
    
    foreach ($calendars as $calendar) {
        echo "Calendar ID: " . $calendar->getId();
    }
    
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.