Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to discover APIs in Google OAuth2 in Node.js

I've got a problem with .discover method in Node.js. I've got such a piece of code:

googleapis.discover('oauth2', 'v2').execute(function(err, client){
    if(!err)
        callback(client);
});

And it throws error: TypeError: Object # has no method 'discover' But in all tutorials there is such a method mentioned. Does anyone know what's wrong?

like image 413
kuba12 Avatar asked Dec 21 '25 02:12

kuba12


1 Answers

I got the same error. I think they updated the googleapis client for Node.

Try follow the new syntax or use older version:

var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
var drive = google.drive({ version: 'v2', auth: oauth2Client });
like image 180
user1509468 Avatar answered Dec 22 '25 16:12

user1509468