wanasit / google-calendar Goto Github PK
View Code? Open in Web Editor NEWGoogle Calendar API connection in Node.js
License: MIT License
Google Calendar API connection in Node.js
License: MIT License
Node 14+
const calendar = new gcal.GoogleCalendar(accessToken);
calendar.events.list(
// arguments
);
Node crashes with the following error:
Error [ERR_METHOD_NOT_IMPLEMENTED]: The _read() method is not implemented
0|www | at new NodeError (node:internal/errors:371:5)
0|www | at Readable._read (node:internal/streams/readable:651:9)
0|www | at Readable.read (node:internal/streams/readable:487:10)
0|www | at maybeReadMore_ (node:internal/streams/readable:638:12)
0|www | at processTicksAndRejections (node:internal/process/task_queues:83:21) {
0|www | code: 'ERR_METHOD_NOT_IMPLEMENTED'
0|www | }
0|www | Error [ERR_METHOD_NOT_IMPLEMENTED]: The _read() method is not implemented
0|www | at new NodeError (node:internal/errors:371:5)
0|www | at Readable._read (node:internal/streams/readable:651:9)
0|www | at Readable.read (node:internal/streams/readable:487:10)
0|www | at maybeReadMore_ (node:internal/streams/readable:638:12)
0|www | at processTicksAndRejections (node:internal/process/task_queues:83:21)
Hi,
After a given amount of query/time the accessToken is rejected. How should I use the refresh token without asking the user ?
Regards
Please help,
I have tried creating new events using this package, my code is like this :
var google_calendar = new gcal.GoogleCalendar(req.user.token);
var resource = {
'summary': 'Google I/O 2019',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google's developer products.',
"guestsCanInviteOthers": false,
'start': {
'dateTime': '2019-01-27T04:00:00+07:00',
'timeZone': 'Asia/Jakarta',
},
'end': {
'dateTime': '2019-01-28T04:00:00+07:00',
'timeZone': 'Asia/Jakarta',
},
"attachments": [
{
"fileId": "1",
"fileUrl": "https://gnusa.id/asset/img/preloader-image-retina-2.png",
"iconLink": "https://gnusa.id/asset/img/preloader-image-retina-2.png",
"mimeType": "image/png",
"title": "Logo Gnusa"
}
],
'attendees': [
{
'email': '[email protected]',
"displayName": "Denis Muhammad Ramdan",
"comment": "Pembicara dari PT. Gateway Internusa",
"organizer": false
}
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10}
],
},
};
google_calendar.events.insert('primary',{
'sendNotifications': true,
'resource': resource,
}, function(err, event) {
if (err) {
console.log('There was an error contacting the Calendar service: ' + JSON.stringify(err));
return;
}
console.log('Event created: %s', event.htmlLink);
});
when the function is executed, the return results are as follows:
There was an error contacting the Calendar service: {"errors":[{"domain":"global","reason":"required","message":"Missing end time."}],"code":400,"message":"Missing end time."}
and the event does not enter the calendar,
my question, why did that happen? Am I writing wrong? if yes, how is the correct writing,
thank you
Heads up - This package as of 1.3.2 has loads of security issues as reported by npm audit, see below...
Manual Review
Some vulnerabilities require your attention to resolve
Visit https://go.npm.me/audit-guide for additional guidance
High Regular Expression Denial of Service
Package fresh
Patched in >= 0.5.2
Dependency of google-calendar
Path google-calendar > express > connect > fresh
More info https://nodesecurity.io/advisories/526
High Regular Expression Denial of Service
Package fresh
Patched in >= 0.5.2
Dependency of google-calendar
Path google-calendar > express > connect > send > fresh
More info https://nodesecurity.io/advisories/526
High Regular Expression Denial of Service
Package fresh
Patched in >= 0.5.2
Dependency of google-calendar
Path google-calendar > express > fresh
More info https://nodesecurity.io/advisories/526
High Regular Expression Denial of Service
Package fresh
Patched in >= 0.5.2
Dependency of google-calendar
Path google-calendar > express > send > fresh
More info https://nodesecurity.io/advisories/526
High Denial-of-Service Memory Exhaustion
Package qs
Patched in >= 1.x
Dependency of google-calendar
Path google-calendar > express > connect > qs
More info https://nodesecurity.io/advisories/29
High Denial-of-Service Extended Event Loop Blocking
Package qs
Patched in >= 1.x
Dependency of google-calendar
Path google-calendar > express > connect > qs
More info https://nodesecurity.io/advisories/28
Moderate Timing Attack
Package cookie-signature
Patched in >=1.0.6
Dependency of google-calendar
Path google-calendar > express > connect > cookie-signature
More info https://nodesecurity.io/advisories/134
Moderate Timing Attack
Package cookie-signature
Patched in >=1.0.6
Dependency of google-calendar
Path google-calendar > express > cookie-signature
More info https://nodesecurity.io/advisories/134
Low Directory Traversal
Package send
Patched in >= 0.8.4
Dependency of google-calendar
Path google-calendar > express > connect > send
More info https://nodesecurity.io/advisories/32
Low Directory Traversal
Package send
Patched in >= 0.8.4
Dependency of google-calendar
Path google-calendar > express > send
More info https://nodesecurity.io/advisories/32
Low Root Path Disclosure
Package send
Patched in >=0.11.1
Dependency of google-calendar
Path google-calendar > express > connect > send
More info https://nodesecurity.io/advisories/56
Low Root Path Disclosure
Package send
Patched in >=0.11.1
Dependency of google-calendar
Path google-calendar > express > send
More info https://nodesecurity.io/advisories/56
Moderate Regular Expression Denial of Service
Package mime
Patched in >= 1.4.1 < 2.0.0 || >= 2.0.3
Dependency of google-calendar
Path google-calendar > express > connect > send > mime
More info https://nodesecurity.io/advisories/535
Moderate Regular Expression Denial of Service
Package mime
Patched in >= 1.4.1 < 2.0.0 || >= 2.0.3
Dependency of google-calendar
Path google-calendar > express > send > mime
More info https://nodesecurity.io/advisories/535
Moderate No Charset in Content-Type Header
Package express
Patched in >=3.11 <4 || >=4.5
Dependency of google-calendar
Path google-calendar > express
More info https://nodesecurity.io/advisories/8
I need help :c I don't know how to use the insert method in calendars module
Creating a new calendar regularly takes more than 10 seconds, resulting in a timeout. The needle
library used has a default timeout of 10 seconds, but I if I see it correctly there is no way to pass a timeout
to needle
via google-calendar
: the 4th argument options
of the request is always an empty object {}
.
Calendars.prototype.insert = function(calendar, option, callback) {
if(!callback){ callback = option; option = {}; }
this.request('POST', '/calendars', option, {}, calendar, callback);
}
https://github.com/wanasit/google-calendar/blob/master/GoogleCalendar.js#L156
It would be great to have an option to apply an other timeout, either globally or per request.
Hello I'm already using google authentication with passportjs. i have an accessToken and i can store it in the session. How can i create new instance of google calendar without all those secrets, but just with an already obtained accessToken.
Request type in events.patch method should be changed to 'PATCH' which is mistaken as 'POST'
Corrected code is in here
https://github.com/prasadKodeInCloud/google-calendar/blob/master/GoogleCalendar.js#L279
Any request returns an error 401 (Login Required)
var gcal = require('google-calendar');
var google_calendar = new gcal.GoogleCalendar("API KEY");
google_calendar.calendarList.list(function(err, calendarList) {
console.log(calendarList)
});
Returning error
{ errors: [ { domain: 'global', reason: 'required', message: 'Login Required', locationType: 'header', location: 'Authorization' } ], code: 401, message: 'Login Required' }
Hello,
I want to create, edit or delete events from my web app without the user having to login.
I should be able to handle my authentication on servr side may be?
Any idea or example to explain this?
Hi there,
I try to count all events from a calendar by day. To do so I need to retrieve all events from a calendar.
I set maxResults parameter up to 10 000 but I still get only 2 500 events.
Have you experienced this issue before ?
Thanks,
Martin
Would it be possible to update to 3.x?
The free/busy endpoint doesn't use typical query parameters. It uses the resquest body in json format.
https://developers.google.com/google-apps/calendar/v3/reference/freebusy/query
hello
In functions getEvent, deleteEvent and updateEvent is missing / character. It is ("/events") and it should be ("/events/").
I had really fun time, to findout why is my deleteEvent function not working.
how can I do this?
thanks
I am using the Google Calendar api to access users' events. I want to access all of the users events that are marked as "busy." I can't use the freebusy
api since I need the actual event details. Here's what I currently have:
gcal(accessToken).events.list(
calendars[inc].id,
{
orderBy: 'startTime',
maxResults: 2500,
singleEvents: true,
timeMax: max.toISOString(),
timeMin: min.toISOString()
},
(err, data) => {
// ...
}
);
This works fine. How can I limit the results to only events marked as "busy"? (So excluding, for example holidays, or day-long reminder events that the user has marked as "available.")
Thank you
NOTE: this is a duplicate of this StackOverflow post.
{ errors:
[ { domain: 'global',
reason: 'invalid',
message: 'Invalid resource id value.' } ],
code: 400,
message: 'Invalid resource id value.' }
Q: May I know how can I fix the error above?
Thanks!
from the Acl delete method:
Acl.prototype.delete = function(calendarId, ruleId, callback) {
calendarId = encodeURIComponent(calendarId);
ruleId = encodeURIComponent(ruleId);
this.request('DEL', '/calendars/' + calendarId + '/acl/' + ruleId,
{}, {}, null, callback);
}
Hi Wanasi,
I am trying to get the update events but now able to pass orderby value as
it is string.
Will you please tell me how to pass this value so the api return me the updated events?
Thanks for the help
I am using async.each to insert events into google calendar.
I am not sure if I am implementing it the right way it is supposed to, can you please help?
I am using the latest versions, updated node to 8.x to see if it fixes the issue but it didnt.
async.each(req.dates,function(value,callback){
var google_calendar = new gcal.GoogleCalendar(req.user.accessToken);
google_calendar.events.insert(req.gmailid,event, function(err,data) {
if (err)
{
console.log(err);
callback(err)
return;
}
else{
console.log(data);
callback();
}
});
},function (err){
if (err){
console.log(err);
res.send('THIS IS THE CULPRIT '+ err);
} else {
console.log(googleResponse);
res.sendStatus(200).send("Reminder added SuccessFully");
}
})
});
I get Cannot set headers after they are sent in the terminal
and this from the debug session.
null: Error: socket hang up
null: Error: socket hang up
code: "ECONNRESET"
message: "socket hang up"
stack: "Error: socket hang up
at createHangUpError (_http_client.js:331:15)
at TLSSocket.socketCloseListener (_http_client.js:363:23)
at emitOne (events.js:121:20)
at TLSSocket.emit (events.js:211:7)
at Socket._destroy.cb._handle.close (net.js:554:12)
at TCP.done [as _onclose] (_tls_wrap.js:356:7)"
proto: Object {constructor: , name: "Error", message: "", …}
constructor: function Error() { … }
BluebirdErrorTypes: Object {CancellationError: , TimeoutError: , OperationalError: , …}
arguments: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
caller: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
captureStackTrace: function captureStackTrace() { … }
arguments: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
caller: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
length: 2
name: "captureStackTrace"
proto: function () { … }
length: 1
name: "Error"
prepareStackTrace: undefined
prototype: Object {constructor: , name: "Error", message: "", …}
constructor: function Error() { … }
BluebirdErrorTypes: Object {CancellationError: , TimeoutError: , OperationalError: , …}
arguments: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
caller: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
captureStackTrace: function captureStackTrace() { … }
length: 1
name: "Error"
prepareStackTrace: undefined
prototype: Object {constructor: , name: "Error", message: "", …}
stackTraceLimit: 16
proto: function () { … }
message: ""
name: "Error"
toString: function toString() { … }
proto: Object {constructor: , defineGetter: , defineSetter: , …}
stackTraceLimit: 16
proto: function () { … }
message: ""
name: "Error"
toString: function toString() { … }
arguments: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
caller: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
length: 0
name: "toString"
proto: function () { … }
proto: Object {constructor: , defineGetter: , defineSetter: , …}
In the Post gCal
null: Error: socket hang up
null: Error: socket hang up
Hi there,
Sorry for this noob question but it seems I do something wrong while trying to lauch one of your example.
When lauching edit-example.js
for instance I get Erreur :invalid_client
.
I also try to edit key and secret in the config file without success..
Do you have any hint ?
Thanks !
Martin
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.