I'm trying to set up Google calendar API on Node, using the Node.js quick start that appear here
After following all the first 3 steps and running my quickstart.js to check if it works (which i copied and pasted from the quickstart) , i get the following error:
"TypeError: googlAuth is not a constructor" it refer to this line of code :
var auth = new googleAuth();
googleAuth is declared like that:
var googleAuth = require('google-auth-library');
i couldnt find any solution online.
the full code is on the link above on the third step. thanks in advance, Assaf.
The version has changed like answers here say. According to the new docs, you must require the package like this:
const gal = require('google-auth-library');
const auth = new gal.GoogleAuth();
const jwtClient = new gal.JWT();
const oAuth2Client = new gal.OAuth2Client();
...
// if you're using Node 6+, you might find this convenient:
const {GoogleAuth, JWT, OAuth2Client} = require('google-auth-library');
The old way used to be like this:
var GoogleAuth = require('google-auth-library');
var auth = new GoogleAuth();
var jwtClient = new auth.JWT();
var oAuth2Client = new auth.OAuth2();
Basically what changed is the way to reference GoogleAuth
. It is now one part of the entire package instead of being the main export.
This change worked for me!
I think this is mostly a nodejs and google library installation problem. I'm running node v8.2.1
on my system and I'm able to execute the nodejs quickstart properly. Try installing latest nodejs and execute these lines again.
npm install googleapis --save
npm install google-auth-library@0.* --save
I think this is mostly a nodejs and google library installation problem. I'm running node v8.2.1
on my system and I'm able to execute the nodejs quickstart properly. Try installing latest nodejs and execute these lines again.
npm install googleapis --save
npm install google-auth-library@0.* --save
Google recently released version 1.0.0
. If you installed without a version npm
would have installed the latest. In that case your code should be:
const {GoogleAuth} = require('google-auth-library');
const auth = new GoogleAuth();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With