Google Calendar Connector
With OMD Go, it is possible to have scheduled events (tasks, breaks, work patterns) pushed to the Google calendar of a resource. For this to work, the resource must have a Google Workspace account. The resource’s email address must be associated with the resource in OMD Go. Events are synced with the resource’s primary calendar.
Setting up a service account
The OMD Google Calendar sync service uses a service account. The service account needs to be created in the Google Workspace administration interface. The service account will use ‘Domain Wide delegation’ to get delegated access to each user's calendar.
The procedure below accomplishes the following:
Register a new project
Add the Calendar API to the project
Create a service account
Create a private key for the service account
Grant the service account access to the calendars of all users
Steps:
Open the Google Cloud Console: https://console.cloud.google.com/
Create a new project with a name describing it's purpose, eg OMD Calendar Sync Service. Set the organization and location to optimizemyday.com.
Go to API Library and add Calendar API. Enable the API by clicking on Enable.
Click on Credentials, click Create Credentials and choose Service account.
Enter a descriptive name for the service account, eg omd-calendar-service-account. Click Create and continue.
Click on the email address of the service account, and click on 'Keys'.
Click on Add key and Create key and choose the JSON format.
Save the created JSON to a safe location (eg Keepass). The contents of this file are needed for the google.calendar.keyfile preference in OMD Go.
Login to the Admin console: https://admin.google.com/
Go to Security > Access and data control > API controls > Manage Domain Wide Delegation. Click on Add new. Enter the service accounts id from step 5. Add the following scopes: https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/calendar.events
All done!
OMD Google Calendar Service
This service is based on Google Calendar API (https://developers.google.com/calendar/api/guides/overview). It makes use of the Google supplied Java libraries from https://developers.google.com/api-client-library/java.
By default, the service will be deployed using the following path/context: https://www.optimizemyday.com/omd-calendar-google/rest/v1/google-calendar.
The service offers a REST API with the following methods:
Method | Parameters | Description |
---|---|---|
users | List all users this application has access to. Can be used to check if the application is configured correctly. | |
push | Process (upsert/delete) all messages in the calendar update table destined for the Google calendar service. Normally, a job is configured that calls this method periodically. | |
verify | email, configId, from, to | Check for each OMD event (task, break, rwp) how many corresponding calendar events are present. |
delete | email, configId, from, to | Delete all calendar entries for the given OMD events. |
upsert | email, configId, from, to | Update or insert calendar entries for the given OMD events. |
sync | email, configId, from, to | Ensure that the users calendar corresponds with the relevant OMD events, creating or deleting calendar entries when necessary. |
Workflow
Whenever a task or event is inserted, updated or deleted, the CalendarListener in OMD Domain (S5 tier) will place events (tasks or breaks) onto the CalendarUpdate table, if the preferences of the configuration request to do so.
When the 'push' method is called (either manually from the browser, or using a tool like curl), all events destined for this service are read and processed sequentially. In case not all entries were processed succesfully, the service will use exponential backoff mechanism to retry at a later time.
Possible errors or exceptions are written to the standard log.
Note that the /sync
API does not adjust any existing tasks in the Google agenda if the Microsoft 365 event has been changed manually by the user. However, events that were removed from the Google agenda are again re-created.
Configuring the service in OMD
Parameters (global)
Parameter Name | Default | Description |
---|---|---|
calendar.google.retryOnBlacklist | false | If true, set a retry timer in case of error or timeout. |
calendar.google.adaptSynchronizable | false | If true, when the resource is marked to not synchronize, set events for the resource to unsynchronizable, effectively ignoring them the next iteration. |
Preferences (per configuration)
Preference Name | Default | Description |
---|---|---|
syncWithGoogleCalendar | false | Used to turn synchronization with Google calendars on or off. |
calendar.google.keyfile | The contents of the Key file JSON for the Service Account used for delegated access to the calendars. | |
calendar.google.timeZone | Europe/Berlin | The time zone to use when creating calendar entries. |
calendar.google.daysBack | 365 | Max number of days in the past to look in the users calendar. Any events older that that will not be queried. |