Load Google JS Client library in Meteor


#1

I am trying to load the Google Client Library to use Google Calendar
in my Meteor application but my callback (onload=handleClientLoad)
function is not executing. The same is working when using from simple
html +javascript app. I have also registered my meteor application url
localhost:3000 in google authorize urls.

Can anyone help me to make this working?

Template.hello.events({
‘click button’: function () {
callGoogle();
}
});

function callGoogle() {
jQuery.ajax({
url: ‘https://apis.google.com/js/client.js?onload=handleClientLoad’,
dataType: ‘script’,
success: function () {
console.log(“Success”);

    },
    error: function (e) { console.log("Error") },
    async: true
});

return false;}

//This function is not executing
function handleClientLoad() {
console.log(“handleClientLoad”);

gapi.client.setApiKey(apiKey);
window.setTimeout(checkAuth, 2);

}

function checkAuth() {
gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: false }, handleAuthResult);
}

function handleAuthResult(authResult) {

console.log("authResult", authResult);
if (authResult && !authResult.error) {
    gapi.client.load('calendar', 'v3', listUpcomingEvents);
}

}

function listUpcomingEvents() {
var request = gapi.client.calendar.events.list({
‘calendarId’: ‘primary’,
‘timeMin’: (new Date()).toISOString(),
‘showDeleted’: false,
‘singleEvents’: true,
‘maxResults’: 10,
‘orderBy’: ‘startTime’
});