无法访问 googleapis auth.OAuth2 for google calender api

Not able to access googleapis auth.OAuth2 for google calender api

下面的代码是从node.js quickstart of Google calender Api section.This code is not able to access auth from google API's.I copied the error below.To see full code you can access this link粘贴的。感谢您的帮助。

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

错误如下所示:

const OAuth2Client = google.auth.OAuth2; ^
TypeError: Cannot read property 'OAuth2' of undefined

试一试:

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