Skip to content

Instantly share code, notes, and snippets.

@melvinkcx
Last active June 30, 2019 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melvinkcx/c293a76b6cf844eb3e66a3a35762adaa to your computer and use it in GitHub Desktop.
Save melvinkcx/c293a76b6cf844eb3e66a3a35762adaa to your computer and use it in GitHub Desktop.
Snippet for "Integrating Google Calendar (G-suite) in Node" https://hackernoon.com/my-journey-integrating-google-calendar-g-suite-in-node-62fbc8596455
const google = require("googleapis").google;
const calendar = google.calendar("v3");
(async function () {
const scopes = ['https://www.googleapis.com/auth/calendar'];
const keyFile = './xxxxxxxxxxx.json'; // Your should make it an environment variable
const client = await google.auth.getClient({
keyFile,
scopes,
});
// Delegated Credential
client.subject = "melvin@xxxxxxxxx.xx";
const res = await calendar.calendarList.list({
auth: client
});
console.log(JSON.stringify(res.data));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment