无法访问Google日历api的googleapis auth.OAuth2

Kap*_*dav 2 google-calendar-api google-api node.js node-modules

下面的代码是从Google日历Api部分的node.js快速入门中粘贴的。此代码无法从google API的auth中访问。我复制了以下错误。要查看完整的代码,您可以访问此链接。谢谢。

const google = require('googleapis');
const OAuth2Client = google.auth.OAuth2;
Run Code Online (Sandbox Code Playgroud)

错误看起来像这样:

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

a5r*_*r0n 5

试试吧:

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