Hi,
In Google Calendar API Node.js Quickstart example, when calendar.events.list() method is called with different parameters values for timeMin and maxResults, returned result is not affected with these changes.Always returns my all events.
function listEvents(auth) {
var calendar = google.calendar('v3');
calendar.events.list({
auth: auth,
calendarId: 'primary',
timeMin: (new Date()).toISOString(),
maxResults: 4,
singleEvents: true,
orderBy: 'startTime'
}, function(err, response) {
if (err) {
console.log('The API returned an error: ' + err);
return;
}
var events = response.items;
if (events.length == 0) {
console.log('No upcoming events found.');
} else {
console.log('Upcoming 4 events:');
for (var i = 0; i < events.length; i++) {
var event = events[i];
var start = event.start.dateTime || event.start.date;
console.log('%s - %s', start, event.summary);
}
}
});
}
But it is working in APIs Explorer.
Thanks!
I have the exact same problem. It's not just you :(
After a long time of googling I found the solution at stackoverflow. The way you have to define the query has changed. Have a look at this thread: https://stackoverflow.com/questions/48488105/google-calendar-api-v3-doesnt-respect-timemin-timemax-parameters-in-nodejs-expr
@dukeks , thank you! it is worked.
Greetings folks! The answer is to actually remove google-auth-library from your package.json. This library installs a compatible version that will work with the original code. We are going to update the docs, but yeah.
I am literally only copying and pasting the quickstart code and following all the instructions to a tee, and don't have any 'google-auth-library' to remove in my package.json file. I have 'passpport-google-oauth20' and 'googleapis' though. removing those don't help.
Greetings! Can you share a link to the quickstart you're following? And provide the error you're getting? Thanks!
It's THE quickstart guide for Node and Google Calendar API. I can only fine
one, but here is the link.
https://developers.google.com/calendar/quickstart/nodejs
According to my troubleshooting research, this has been a problem for quite
some time. There are many posts about this in the github issues section of
these libraries.
https://github.com/google/google-auth-library-nodejs/issues/251
"
/Users/jackgray/webapps/bcd/server/quickstart.js:5
const OAuth2Client = google.auth.OAuth2;
^
TypeError: Cannot read property 'OAuth2' of undefined
at Object.<anonymous>
(/Users/jackgray/webapps/bcd/server/quickstart.js:5:34)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
"
On Sat, Apr 28, 2018 at 5:35 PM, Justin Beckwith notifications@github.com
wrote:
Greetings! Can you share a link to the quickstart you're following? And
provide the error you're getting? Thanks!—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/google-api-nodejs-client/issues/1041#issuecomment-385207087,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA999Glldt0ECazrcKYyEB43_GymT_ISks5ttOCYgaJpZM4Semwd
.
"dependencies": {
"body-parser": "^1.17.2",
"concurrently": "^3.5.0",
"cookie-session": "^2.0.0-beta.2",
"express": "^4.15.3",
"fs": "0.0.1-security",
"google-auth-library": "^0.12.0",
"googleapis": "^27.0.0",
"localtunnel": "^1.8.3",
"lodash": "^4.17.4",
"mkdirp": "^0.5.1",
"mongoose": "^4.11.1",
"nodemon": "^1.11.0",
"passport": "^0.3.2",
"path-parser": "^2.0.2",
"readlines": "^0.2.0",
"save": "^2.3.2",
"sendgrid": "^5.1.2",
"stripe": "^4.23.1"
}
Is there a particular version of Node I should be running? I have tried a
few old and new..
On Sun, Apr 29, 2018 at 9:58 AM, Jack Gray jgrayau@gmail.com wrote:
It's THE quickstart guide for Node and Google Calendar API. I can only
fine one, but here is the link.https://developers.google.com/calendar/quickstart/nodejs
According to my troubleshooting research, this has been a problem for
quite some time. There are many posts about this in the github issues
section of these libraries.https://github.com/google/google-auth-library-nodejs/issues/251
"
/Users/jackgray/webapps/bcd/server/quickstart.js:5
const OAuth2Client = google.auth.OAuth2;
^TypeError: Cannot read property 'OAuth2' of undefined
at Object.<anonymous> (/Users/jackgray/webapps/bcd/server/quickstart.js:5:34)
at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) at Function.Module.runMain (module.js:684:10) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3"
On Sat, Apr 28, 2018 at 5:35 PM, Justin Beckwith <[email protected]
wrote:
Greetings! Can you share a link to the quickstart you're following? And
provide the error you're getting? Thanks!—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/google-api-nodejs-client/issues/1041#issuecomment-385207087,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA999Glldt0ECazrcKYyEB43_GymT_ISks5ttOCYgaJpZM4Semwd
.
Greetings! The quickstart is out of date. We're working to fix that :) You just need to change this:
const google = require('googleapis');
To this:
const {google} = require('googleapis');
Apologies for the trouble, and hope this helps!
I really appreciate your prompt reply, but that doesn’t solve the entire problem.. I can’t remember what the next error is, but there is a string of them once you start destructuring these definitions. I’ll follow up when I’m back at my console.
Thanks!
Sent from my iPhone
On Apr 29, 2018, at 12:07 PM, Justin Beckwith notifications@github.com wrote:
Greetings! The quickstart is out of date. We're working to fix that :) You just need to change this:
const google = require('googleapis');
To this:const {google} = require('googleapis');
Apologies for the trouble, and hope this helps!—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
Most helpful comment
Greetings! The quickstart is out of date. We're working to fix that :) You just need to change this:
To this:
Apologies for the trouble, and hope this helps!