I'm working on a script for management of shared calendars using a service account. For security and compliance reasons, we cannot use application level permissions and the service account only has delegate permissions. This requires that users opting into the service share their calendars with the service account.
The goal is to be able to list all of the shared calendars for the service account using
GET https://graph.microsoft.com/v1.0/me/calendars
and manage each of those calendars (events being created, deleted, edited, etc.) using
POST https://graph.microsoft.com/v1.0/me/calendars/{shared-calendar-id}/events
or
PATCH or DELETE https://graph.microsoft.com/v1.0/me/calendars/{shared-calendar-id}/events/{event-id}
That all works fine once the calendar has been shared and accepted. The problem is accepting the share invitation. Since the introduction of the "new" sharing system, the recipient of the share receives a sharing notification in their mailbox which they have to accept.
Being that this is a service account and dealing with several hundred users, manually checking and accepting all of the share invites will not be feasible and we need a programmatic way of doing this.
Is there an MS Graph endpoint to accept a calendar share invite?
Once a user sends a calendar share invite, parsing messages using
GET https://graph.microsoft.com/v1.0/me/messages
the calendar invite shows up as having these additional fields
"@odata.type": "#microsoft.graph.calendarSharingMessage",
"sharingMessageAction": {
"importance": "primary",
"actionType": "accept",
"action": "acceptAndViewCalendar"
},
"sharingMessageActions": [
{
"importance": "primary",
"actionType": "accept",
"action": "acceptAndViewCalendar"
}
]
Furthermore, the calendar becomes visible with the below endpoint
GET https://graph.microsoft.com/v1.0/users/{user-id}/calendars/
but is not listed on /me/calendars until the invite is accepted (and the shared copy is created).
There is an accept url in the body of the share invite email, but trying to use this url always results in a 500 error.
The documentation covers accepting a shared event where POST to the /tentativelyAccept endpoint of the event is used. Unfortunately I have been unable to find any similar documentation for calendar shares.
If anyone has a way to accept calendar share invites that do not involve manually clicking on the button in the email, please let me know :)
Thanks!