Node.js Google Calendar API Official Library to Build Calendar on Website Full Project For Beginners




Google Calendar library for Node.js

npm install googlecalendar

For 0.0.x users

This module (1.x.x) has been redesigned completely, so it is incompatible with the old version. The 0.0.x version is moved to branch name v0.


AccessToken & Authentication

This library requires Google API’s Access Token with calendars scope.

var gcal = require(google-calendar);
var google_calendar = new gcal.GoogleCalendar(accessToken);

To get accessToken, use another authentication framework such as passport (recommended, but not required) for OAuth 2.0 authentication. You can take look at the 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,] 
  function(accessToken, refreshToken, profile, done) {
    //google_calendar = new gcal.GoogleCalendar(accessToken);
    return done(null, profile);

API Usage

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) {
 , function(err, calendarList) {

Leave a Reply