calendar Quickstart.js should write token using fs.writeFileSync, not fs.writeFile.
See original GitHub issuefs.writeFile does not wait for the writing to complete, and I would end up with an empty /.credentials/calednar-nodejs-quickstart.json file. This of course would crash the app on subsequent starts as it either expects the file to NOT EXIST, or it to exist and have some data.
My fix was to replace fs.writeFile(TOKEN_PATH, JSON.stringify(token));
with fs.writeFileSync(TOKEN_PATH, JSON.stringify(token), 'utf8');
, thus insuring that the program actually writes the file.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
NodeJS, Google Calendar API integration not authenticated ...
One of my problems was that when you, use Googles quickstart for NodeJS to connect to the Calendar API, that code will ask...
Read more >sheets quickstart.js needs updating to reflect the es6 ... - GitHub
Hi, quickstart.js ( taken from https://developers.google.com/sheets/api/quickstart/nodejs ) currently fails when trying to reference ...
Read more >Node.js quickstart | Google Calendar
Quickstarts explain how to set up and run an app that calls a Google Workspace API. Google Workspace quickstarts use the API client...
Read more >How to integrate Google Calendar in Node.js ? - GeeksforGeeks
This article covers the integration of Google Calendar API in the NodeJS application and creating new events with service account ...
Read more >Node.js v19.3.0 Documentation
This will print to the file and will not invoke AsyncHook recursively because it is synchronous. import { writeFileSync } from 'node:fs'; import...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah! So yes, the tutorial is out of date. However, the readFile part looks right. We’re in the process of updating and testing out samples, so apologies for the confusion!
The tutorial at https://developers.google.com/google-apps/calendar/quickstart/nodejs still seems to reference fs.writeFile instead of fs.writeFileSync. Was it updated somewhere else?
And if not changed already, the
const google = require('googleapis');
should beconst {google} = require('googleapis');
(same as #999 )