Reputation: 1976
I have a problem with the NodeJs googleapis module.
My Simple Test:
var google = require('googleapis');
var analytics = new google.analytics('v3');
var OAuth2 = google.auth.OAuth2;
var config = require('./config.js')
var oauth2Client = new OAuth2(config.clientId, config.clientSecret);
// Retrieve tokens via token exchange explained above or set them:
oauth2Client.setCredentials({
access_token: config.accessToken,
refresh_token: config.refreshToken
});
// get management list
analytics.management.accounts.list({ auth: oauth2Client }, function(err, response) {
console.log(err)
console.log(response)
});
My Result:
Type Error: Cannot read property 'params' of undefined
at createAPIRequest (/Users/gkburdett/Documents/Applications/maestro-and-scout/node_modules/googleapis/lib/apirequest.js:76:39)
at Object.Analytics.management.accounts.list (/Users/gkburdett/Documents/Applications/maestro-and-scout/node_modules/googleapis/apis/analytics/v3.js:342:16)
at Object.<anonymous> (/Users/gkburdett/Documents/Applications/maestro-and-scout/server/google/test/simpleTest.js:13:31)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
parameters.context.google is a blank object.
It works if I change apirequest.js line 76 to a blank object. I submitted an issue on GitHub, but I have a hard time believing I'm the only one having this problem if it's a problem with the library.
Upvotes: 2
Views: 949
Reputation: 703
There was a method in my api with a name that started with "google" and it was overriding some internal config object of the library. I am not a guru to judge anyone but it seems like a poor design to mix internal and user-defined methods in one object
Upvotes: 0
Reputation: 31
Change line 2 from:
var analytics = new google.analytics('v3');
to:
var analytics = google.analytics('v3');
When calling analytics.management.accounts.list
the context options being passed to createAPIRequest
are out of scope to the initial google
object.
Upvotes: 3