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]”

How to stop getting Google document requests to edit from users outside your organisation from publicly viewable files. (Updated Feb 2022)

G Suite – Paid editions, Gmail, Google Sheets, Google Docs, Google Slides, Google Drive

Recently, I had updated all the course materials in a learning management system (Not Google Classroom. Sorry Google) to only use Google Workspace files like Docs, Sheets and Slides for students to access.

For me, this was a pretty logical step. It allowed course creators to update their files live when they had to correct errors or make minor changes quarter-to-quarter or year-to-year. Administratively, it meant that files did not have to be accounted for, deleted and updated every time a change was made.

The Problem

While time-consuming, the changeover went well as we changed all of the student resources into Google files. We set all the files to be accessible to anyone with the link can view (The organization does not have student accounts on the same domain as the staff).

Google sharing settings

However, in the back of my mind, there was a problem I knew I needed to address. The dreaded request for access to edit. With over 3,500 students on the program and hundreds of files for them to access, it would be a huge pain if some of these students clicked that view and requested edit access.

Google Docs View Only - Request Edit Access

There is no way to prevent users from not being able to do this within the document’s share options. Likewise, my organisation may want to allow requests inside the domain (for example name@yagisanatode.com is okay, but name@gmail.com is not).

The Solution – Gmail Filters

Continue reading “How to stop getting Google document requests to edit from users outside your organisation from publicly viewable files. (Updated Feb 2022)”