First: this article was super helpful and got me 95% of the way to a working solution. So thank you so much for posting it!
Here's what didn't work for me:
When I ran the posted code, I would get this error:
The API returned an error: TypeError: authClient.request is not a function
...which, after googling it, seems like an auth or API version error.
It could be related (or not) to the fact that I am not using a G-Suite account. So for anyone wondering how to make it work for a regular google account, here's how!
...as the service account email already exists in the credentials file (under the "client_email" key).
So the end-result is even more simple, thanks to google.auth.GoogleAuth().
And it might work for G-Suite accounts too. (So if anyone with a G-Suite account wants to try this, please post here to let us know if this worked for you too.)
Hi, I am Balinder, a Software Engineer -> enthusiastic about learning what I don't know and sharing what I know and trying to prioritize sharing over learning - because that makes more sense :)
First: this article was super helpful and got me 95% of the way to a working solution. So thank you so much for posting it!
Here's what didn't work for me:
When I ran the posted code, I would get this error:
...which, after googling it, seems like an auth or API version error.
It could be related (or not) to the fact that I am not using a G-Suite account. So for anyone wondering how to make it work for a regular google account, here's how!
What I did is I replaced this:
...with this:
(Source: googleapis.dev/nodejs/googleapis/l...)
So in my case, there was no need to
require()
the credentials file (asgoogle.auth.GoogleAuth()
does that for us), so I removed this line:...and I also removed this line:
...as the service account email already exists in the credentials file (under the
"client_email"
key).So the end-result is even more simple, thanks to
google.auth.GoogleAuth()
.And it might work for G-Suite accounts too. (So if anyone with a G-Suite account wants to try this, please post here to let us know if this worked for you too.)
Got the same issue. this change fixed the issue. Awesome tip.