Skip to content

Instantly share code, notes, and snippets.

@Mirochiu
Created March 15, 2022 03:40
Show Gist options
  • Select an option

  • Save Mirochiu/280d66cd93781fd7d2dcbaac8efb5aee to your computer and use it in GitHub Desktop.

Select an option

Save Mirochiu/280d66cd93781fd7d2dcbaac8efb5aee to your computer and use it in GitHub Desktop.
Access Google calendar API with node.js
const { google } = require('googleapis');
const dotenv = require('dotenv');
dotenv.config();
const auth = new google.auth.GoogleAuth({
//keyFile: './client_secret.json', // GOOGLE_APPLICATION_CREDENTIALS
scopes: [
'https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/calendar.events',
],
});
const main = async () => {
const authClient = await auth.getClient();
const calendar = google.calendar({
version: 'v3',
auth: authClient,
})
calendar.calendarList.list().then(res => console.log(res.data));
};
main().catch(console.error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment