-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'OAuth2' of undefined #6
Comments
I already fix this problem at #3 |
No worries. 👍 |
@IshaanRawat Please do! PRs are very welcome and much appreciated. |
@grant I found this issue on many of the Node.js documentation on the Google website also. I would be happy to contribute to those also. |
This change isn't reflected on the sheets page of developers.google.com still! |
Thanks @paigekehoe. |
Thanks, good spot! |
@IshaanRawat Thanks! |
Published. |
In the Google sheets api sample code:
https://github.com/gsuitedevs/node-samples/blob/e426bd6af84904ea49ebd043787659936264727a/sheets/quickstart/index.js#L20
Expected Behavior
The following should be working properly.
const google = require('googleapis');
const OAuth2Client = google.auth.OAuth2;
Actual Behavior
Instead, it is showing
Cannot read property 'OAuth2' of undefined
Steps to Reproduce the Problem
node quickstart.js
.Solution
After debugging the code, I found out that it is using the google property in the google variable that we required from googleapis. This bug was resulting in the undefined behavior as
google.auth
is not defined. What actually defined isgoogle.google.auth
.So what I did was extract the google property directly be using ES6 destructuring which fixed this issue and all the further issues which were created by it.
const {google} = require('googleapis');
Specifications
The text was updated successfully, but these errors were encountered: