Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am very new to node. I am using expressjs.
Here my requirement is to insert an event to google calendar. After googling if found following block of code:

JavaScript
var moment = require('moment');
var googleapis = require('googleapis');
var GoogleToken = require('gapitoken');
var OAuth2Client = googleapis.OAuth2Client;

var token = new GoogleToken({
    iss: '*******************@developer.gserviceaccount.com',
    scope: 'https://www.googleapis.com/auth/calendar',
    keyFile: './*****************.pem'
}, function (err) {
    if (err) {
        return console.log(err);
    }

    token.getToken(function (err, token) {
        if (err) {
            return console.log(err);
        }

        googleapis.load('calendar', 'v3', function (err, client) {
            var oauthClient = new OAuth2Client('', '', '', {}, {
                token_type: 'Bearer',
                access_token: token
            });

            var now = moment().format();

            client
                .calendar
                .events
                .insert({
                    calendarId: 'primary',
                    resource: {
                        summary: 'hangout',
                        description: 'hangout',
                        reminders: {
                            overrides: {
                                method: 'popup',
                                minutes: 0
                            }
                        },
                        start: {
                            dateTime: now
                        },
                        end: {
                            dateTime: now
                        },
                        attendees: [{
                            email: '****@**********.com'
                        }]
                    }
                })
                .withAuthClient(oauthClient)
                .execute(function (err, event) {
                    // event does not contain hangoutLink
                    console.log(event.hangoutLink);
                });
        });
    });
});

But here I dont understand the 'iss', 'scope' and 'keyfile'.

Please help me in this or let me know if any other easy way are there.

My basic requirement to add an event to the calendar.

Thanks
Swarup
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900