Google Apps Script: How to force subscribe Google Group Members to a Google Calendar for G Suite [Update 06 Apr 2022]

Google Apps Script, G Suite Admins, Google Calendar, Calendar API,  AdminDirectory, GroupsAp

Note! This approach no longer force subscribes users to a Calendar. The new approach can be found here. [update 06 Apr 2022]

It appears that the approach below no longer force-subscribes users in a Group to a calendar. Google Made this change in March of 2020, some 7 months after the post was written.

Service accounts created on or after March 2, 2020 are only able to invite guests using domain-wide delegation of authority .

There is also a note in the Sharing Calendars chapter of the Calendar API information stating:

Note: Sharing a calendar with a user no longer automatically inserts the calendar into their CalendarList. If the user should be able to see and interact with the shared calendar, you will also need to call the CalendarList: insert() method.

While this explanation is no doubt helpful for general use, using the insert() method in CalendarList requires that the script be run by the user that needs to be shared.

One hint to a workaround can be found in the update notes referring to the ability to invite guests using domain-wide authority using a service account.

This is a pretty gnarly process to set up and write about and has taken some time to write about and test, but you can now find the tutorial here:

https://yagisanatode.com/2022/04/05/how-to-force-subscribe-a-user-in-your-domain-to-a-google-calendar-in-google-apps-script/

Having said all that, the script below does still contain some interesting use cases for using the Admin SDK service and Advanced Calendar API service in Google Apps Script, so I will leave it up until I can publish a solution.

The script below can now be modified to to extract the users in a group and then use a Service Account on each user to force subscribe them using the code in the tutorial link above.

Big thanks to Jeremy for bringing this to my attention and apologies, I could not find a quick fix.

~ Yagi 06 April 2022

Note! This article is for G Suite users and admins. You won’t be able to apply the same code to Consumer accounts. 

Google Groups in  G Suite can be a really convenient and clean way to share users to drive folders and file locations, email users and set up Google+ community locations. However, I have come across some issues with sharing Google Calendar to Google Groups.

When you assign a Google Group email to a Google Calendar it sends out an email inviting the users in the group to accept the calendar into their list of shared calendars. The user must then accept the invitation before the calendar is added to their Google Calendar list of shared calendars…calendar.

The users receive an email message like this:

Hello Goat_GroupAlpha,

We are writing to let you know that Billy.Goat@yagisanatode.com has given you access to view events on the Google Calendar called “Test”.

Click this link to add the calendar.

– The Google Calendar Team

The Problem

In a large organisation, not all users in a group will add the calendar using the link. This might be okay but if the calendar is important or the user, as is often the case, simply just forgot to add it, then there will be emails to you the admin in the future asking you why they don’t have the calendar that everyone else has and has now missed some important event…sigh.

Another issue is that when a new user is added to a group when the group has already been added to a calendar, then that user will not receive an email invitation to the calendar and won’t be able to see the calendar.

Almost a Solution

Continue reading “Google Apps Script: How to force subscribe Google Group Members to a Google Calendar for G Suite [Update 06 Apr 2022]”