Created
March 15, 2022 03:40
-
-
Save Mirochiu/280d66cd93781fd7d2dcbaac8efb5aee to your computer and use it in GitHub Desktop.
Access Google calendar API with node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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