I'm trying to create a new event using the Google Calendar, I'm currently using their Javascript API. When I try to do the request, the responsive that I get is a 403 - forbidden. I tested the same request with the API Explorer available on the Google Developers page and it worked normally.
Searching for the problem on the internet, I found some solutions, where people said that I need to share my calendar with the Google Service Account I created. I did it and it still doesn't work. Do you guys have any idea how can I solve it?
EDIT
Initialization:
gapi.client.init({
discoveryDocs: DISCOVERY_DOCS,
clientId: CLIENT_ID,
scope: SCOPES
}).then(function () {
if (!(gapi.auth2.getAuthInstance().isSignedIn.get())) {
handleAuthClick();
}
else {
getAvailableTimes();
}
// Listen for sign-in state changes.
// gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
});
Insert action:
modal.result.then(function (interview) {
var eventRequest = gapi.client.calendar.events.insert({
calendarId: interview.recruiter.email,
sendNotifications: true,
resource: {
summary: 'Interview with ' + interview.candidate.name,
description: '',
start: {
dateTime: interview.start
},
end: {
dateTime: interview.end
},
attendees: [
{email: interview.recruiter.email},
{email: interview.candidate.email}
],
reminders: {
useDefault: false,
overrides: [
{method: 'email', minutes: 60 * 24},
{method: 'email', minutes: 60},
{method: 'popup', minutes: 60},
{method: 'email', minutes: 10},
{method: 'popup', minutes: 10}
]
}
}
});
})