A simple Node.JS application that uses REST APIs to update a Google calendar based on data from a Google sheet.
It was written for a very specific use case (that of a spreadsheet used to track availability of volunteers for a code club) so it's unlikely to be generally useful, but it can hopefully serve as a reference or starting-point for anyone looking to do something similar.
Run npm install
to install dependencies.
Follow the linked instructions to enable both the Google Calendar and Google Sheets APIs.
Edit environment.ts to configure the locations of your Google calendar and spreadsheet and other aspects of the application.
Tested on node 10.15.3.
npm run start
- update the calendar with data from the spreadsheetnpm run dry-run
- log the updates that would have been made, without actually making them
The first time you run the application it will prompt you to visit a web site to authenticate - simply follow the instructions in the console. The credentials are save to disk and re-used for future runs.
Run npm install -g $(npm pack | tail -1)
to install the application globally. This will add a google-sheets-calendar-connector
executable to the path.
You can use the TOKEN_DIR
environment variable to control where the API token is stored.
The application does not provide support for scheduling - use an OS provided system such as cron
(linux) or launchd
(MacOS).
docker build -t google-sheets-calendar-connector .
docker volume create google-api-token
docker create -i -v google-api-token:/var/token --name google-sheets-calendar-connector google-sheets-calendar-connector
docker start -i google-sheets-calendar-connector
Follow the instructions to authenticate and then press Ctrl+D
to stop the container.
docker start google-sheets-calendar-connector
The application will run once and the container will stop on completion.
Portions of this code were taken from https://developers.google.com/google-apps/calendar/quickstart/nodejs, licensed under the Apache 2.0 License (http://www.apache.org/licenses/LICENSE-2.0).