I want to create an event in javascript to insert an event in Google Calendar with the following code:
var event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2018-03-7T09:00:00-07:00',
'timeZone': 'Europe/Madrid'
},
'end': {
'dateTime': '2018-03-7T17:00:00-07:00',
'timeZone': 'Europe/Madrid'
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': '[email protected]'},
{'email': '[email protected]'}
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10}
]
}
};
var request = gapi.client.calendar.events.insert({
'calendarId': '[email protected]',
'resource': event
});
request.execute(function(event) {
appendPre('Event created: ' + event.htmlLink);
});
but I get the following error:
Uncaught TypeError: Can not read property 'calendar' of undefined
I think it's because I'm not authorized in the Auth2.0.