Google Calendar library for Node.js
npm install google-calendar
This module (1.x.x) has been redesigned completely. So, it incompatible with the old version. The 0.0.x version is moved to branch name v0.
This library requires Google API's Acceess Token with calendars scope.
var gcal = require('google-calendar');
var google_calendar = new gcal.GoogleCalendar(accessToken);
To get accessToken
, use other authentication framework such as passport (recommended, but not required) for OAuth 2.0 authentication. You can take look at example code in example folder.
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
var passport = require('passport');
var gcal = require('google-calendar');
passport.use(new GoogleStrategy({
clientID: config.consumer_key,
clientSecret: config.consumer_secret,
callbackURL: "http://localhost:8082/auth/callback",
scope: ['openid', 'email', 'https://www.googleapis.com/auth/calendar']
},
function(accessToken, refreshToken, profile, done) {
//google_calendar = new gcal.GoogleCalendar(accessToken);
return done(null, profile);
}
));
This library follows Google Calendar API v3 Reference.
GoogleCalendar.Resource.Method( required_param1, required_param2, optional, callback )
For example
var google_calendar = new gcal.GoogleCalendar(accessToken);
google_calendar.calendarList.list(function(err, calendarList) {
...
google_calendar.events.list(calendarId, function(err, calendarList) {
...
});
});
Calendar List
- GoogleCalendar.calendarList.list = function(option, callback)
Events (Complete)
- GoogleCalendar.events.delete = function(calendarId, eventId, option, callback)
- GoogleCalendar.events.get = function(calendarId, eventId, option, callback)
- GoogleCalendar.events.import = function(calendarId, eventId, option, callback)
- GoogleCalendar.events.insert = function(calendarId, event, option, callback)
- GoogleCalendar.events.instances = function(calendarId, eventId, option, callback)
- GoogleCalendar.events.list = function(calendarId, option, callback)
- GoogleCalendar.events.move = function(calendarId, eventId, option, callback)
- GoogleCalendar.events.quickAdd = function(calendarId, text, callback)
- GoogleCalendar.events.update = function(calendarId, eventId, event, option, callback)
- GoogleCalendar.events.patch = function(calendarId, eventId, patch, option, callback)