Node.js 无法访问google日历api的googleapis auth.OAuth2

Node.js 无法访问google日历api的googleapis auth.OAuth2,node.js,google-api,node-modules,google-calendar-api,Node.js,Google Api,Node Modules,Google Calendar Api,下面的代码是从节的粘贴的。此代码无法从google API访问auth。我复制了下面的错误。要查看完整代码,您可以访问此代码。感谢帮助 const google = require('googleapis'); const OAuth2Client = google.auth.OAuth2; 错误如下所示: const OAuth2Client=google.auth.OAuth2; ^ TypeError:无法读取未定义的属性“OAuth2” 试试看: const{google}=requi

下面的代码是从节的粘贴的。此代码无法从google API访问auth。我复制了下面的错误。要查看完整代码,您可以访问此代码。感谢帮助

const google = require('googleapis');
const OAuth2Client = google.auth.OAuth2;
错误如下所示:

const OAuth2Client=google.auth.OAuth2; ^
TypeError:无法读取未定义的属性“OAuth2”

试试看:

const{google}=require('googleapis');
const OAuth2=google.auth.OAuth2