How use Google Calendar API to insert an event in end-user's calendar with Next.js
Hello,
I'm trying to setup a call to Google Calendar API to insert an event in end-user with Next.js but I'm drowning in the documentation.
I'm stuck on the authentication of the end-user. Here what I've done till now :
- I created a OAuth 2.0 ID Client from Google Cloud Console
- Imported the .json file in my Next.js application
- I used NextAuth and googleapis (Node.js google library for authentification)
- Used the googleapis to try to authenticate the end-user and get an access-token. Here the error message I got : "key must be a string, a buffer or an object"
Here the code creating the error :
I don't understand because keyFilePath is a string.. I've tried to replace it with the content of the file directly, as an object, but then I got the error message : The "paths[0]" argument must be of type string. Received an instance of Object ..
Does anyone has experience with Google APIs, OAuth 2.0 or Next.js ? Or can direct me towards great resources ? I'm a bit lost with all the google documentation.
Thanks !
2 Replies
I don't have any experience so I'm not sure I'll be able to help. Do you have links to the libraries you used though? Especially a link to the documentation of
google.auth.GoogleAuth()
The library I used in my code snipped is googleapis from https://www.npmjs.com/package/googleapis
npm
googleapis
Google APIs Client Library for Node.js. Latest version: 130.0.0, last published: 4 days ago. Start using googleapis in your project by running
npm i googleapis
. There are 2651 other projects in the npm registry using googleapis.