Skip to content

Instantly share code, notes, and snippets.

@wilcoschoneveld
Last active October 14, 2019 13:50
Show Gist options
  • Save wilcoschoneveld/358cab318f40bb97c419dc0f0aac2c56 to your computer and use it in GitHub Desktop.
Save wilcoschoneveld/358cab318f40bb97c419dc0f0aac2c56 to your computer and use it in GitHub Desktop.
// Create a new GoogleAuth instance with service-account credentials from a json file.
// Note: credential file location must be set in GOOGLE_APPLICATION_CREDENTIALS env variable
const auth = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/calendar'],
clientOptions: {
// Overwrite JWT subject to 'impersonate' calendar user
subject: 'wilco@headfwd.com'
}
});
this.calendar = google.calendar({
version: 'v3',
auth: await auth.getClient()
});
this.schedule.scheduleIntervalJob('poller', this.POLLING_INTERVAL, () => this.pollCalendarEvents());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment