question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"OAuth2Client is not a constructor" for google-sheet-sync

See original GitHub issue

I am receiving the following error when attempting to deploy the google-sheet-sync function:

TypeError: OAuth2Client is not a constructor

The error points to line 45 in the index file:

const functionsOauthClient = new OAuth2Client(CONFIG_CLIENT_ID, CONFIG_CLIENT_SECRET, FUNCTIONS_REDIRECT);

I go through the 14 steps laid out exactly, configuring all the IDs and everything else. I believe the issue might also have to do with line 22 in the index file:

const {OAuth2Client} = require('google-auth-library');

Elsewhere (e.g. on stack overflow here and on Google’s GitHub here) people have talked about how the syntax for the OAuth2Client class and the GoogleAuth class was altered slightly, but this code reflects that change and this issue remains.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
FluorescentHallucinogencommented, Mar 11, 2018

See #341. 😉

1reaction
PaulSteenkisteKrikeycommented, Feb 28, 2018

Thanks for getting back to me!

I was using Node version 8.9.4, but I tried updating to 9.6.1 and the issue persisted. I also tried removing the “new” keyword, and the error changed to:

TypeError: OAuth2Client is not a function

so I do not believe that is the issue. Any other suggestions/ideas?

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

googleAuth is not a constructor, google-api version problem
For newer versions, you need to use the OAuth2Client property which you can get with destructuring. Other common properties are auth or JWT ......
Read more >
Missing function in google sheets API leading to error : r/node
GoogleAuth is not a constructor". despite GoogleAuth being explicitly listed in the documentation. For final reference, yes, ...
Read more >
Const authClient = new auth.OAuthClient TypeError
Const authClient = new auth.OAuthClient TypeError: auth.OAuthClient is not a constructor ... Hi, Good spotting, thanks for reporting it. The new ...
Read more >
Node.js quickstart | Google Sheets
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 >
“GoogleSpreadsheet is not a constructor” — How to solve ...
Did you come across this error — “GoogleSpreadsheet is not a constructor”, while connecting nodeJS to google spreadsheets?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found