Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google OAuth TypeError: Cannot read property 'OAuth2' of undefined

I am trying to build an App using Google Calendar API. I am following the guide:https://developers.google.com/calendar/quickstart/nodejs. However, when, I run the project I am getting the below error

TypeError: Cannot read property 'OAuth2' of undefined

TypeError: Cannot read property 'OAuth2' of undefined
at Object.<anonymous> (
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Function.Module.runMain (module.js:701:10)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:618:3

Did someone faced similar issues

like image 235
Dibyendu Roy Avatar asked Aug 31 '25 21:08

Dibyendu Roy


1 Answers

I have solved it:

const {google} = require('googleapis');
const OAuth2Client =google.auth.OAuth2;
like image 99
Li Tianyi Avatar answered Sep 03 '25 23:09

Li Tianyi