This npm module simplifies and connects users with the Google Calendar API, follow step by step. THIS IS A WORK IN PROGRESS
-
To begin, install the package:
npm i npm-google-calendar
-
Create a config folder. There, create a settings.js file where you will access sensitive data from your credentials.
Your settings.js file should be similar to this:
/* You find SERVICE_ACCT_ID from the Service Account ID credentials token you create in the Google Developers Console. */
const SERVICE_ACCT_ID = '<service_account>@<project_name>.iam.gserviceaccount.com';
/* You find this in your calendars "Settings and sharing" */
const CALENDAR_ID = {
'primary': 'main-calendar-id>@gmail.com'
};
const TIMEZONE = 'UTC-05:00';
// or if using json keys - module.exports.key = key;
const key = require('json key you create after making the service account' ).private_key;
module.exports.key = key;
module.exports.serviceAcctId = SERVICE_ACCT_ID;
module.exports.calendarId = CALENDAR_ID;
module.exports.timezone = TIMEZONE;
-
If you have never done so, create a Service Account in the Google Developers Console.
-
Create a project of your chosen name, and enable the Google Calendar API.
-
Proceed by creating credentials of type "Service Account ID" and download the JSON data. Add it your config folder. Remember to update your settings.js with your own SERVICE__ACCT_ID, which is the value of the "client_email" key.