Search code examples
google-calendar-apigcal

How can I create an event on another users google calendar without reminders/notifications


I try to create events for the users in my organization with a service account for which it is not needed that there is a reminder. Things like public holidays etc...

I add to the event a reminders object to override the default:

EventReminder[] reminderOverrides = new EventReminder[] {};
Event.Reminders reminders = new Event.Reminders()
    .setUseDefault(false)
    .setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders)

Unit test and functional tests show there are no reminders attached when I check from a service account.

However when I login with user credentials, the default reminders are still visible.

What do I need to do differently so that people are not disturbed early in the morning on a public holiday?


Solution

  • When using the service account you should be aware to impersonate the user and not use the admin account. When an event is created by the admin account the default settings are taken from the user calendar settings. But when you impersonate the user you can turn off the notifications.

    From the rest API documentation:

    It's possible to specify the email address of the user account with the setServiceAccountUser method of the GoogleCredential factory.