So I have this code and it is working properly ONLY when I am logged in w/ my google account. When I'm not logged in I have to log in in order to continue my create event function. Is there any way to make it so that anyone can add event to my public calendar? I've searched many places but I can't seem to find any answers. :P
var CLIENT_ID = 'MY CLIENT_ID GOES HERE';
var SCOPES = ["https://www.googleapis.com/auth/calendar"];
checkAuth();
function checkAuth() {
gapi.auth.authorize(
{
'client_id': CLIENT_ID,
'scope': SCOPES.join(' '),
'immediate': true
}, handleAuthResult);
}
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
console.log(authResult);
loadCalendarApi();
} else {
gapi.auth.authorize(
{client_id: CLIENT_ID, scope: SCOPES, immediate: false},
handleAuthResult);
return false;
}
}
function loadCalendarApi() {
gapi.client.load('calendar', 'v3', createEvent);
}
function createEvent(){
var resource = {
"summary": eventName,
"location": location,
"description": rid,
"start": {
"dateTime": startNew
},
"end": {
"dateTime": endNew
},
};
var request = gapi.client.calendar.events.insert({
'calendarId': 'MY CALENDAR ID GOES HERE@group.calendar.google.com',
'resource': resource
});
request.execute(function(resp) {
console.log(resp);
callback();
});
}
Notice some of the codes where left out. But everything is working properly.