I'm using the Google Calendar API in my Angular 9 Web Application and trying to create events on a Google Calendar within my G Suite domain
In the G Suite Admin Console, I've given the service account permissions for the scopes https://www.googleapis.com/auth/calendar and https://www.googleapis.com/auth/calendar.events
I created the calendar itself under my account and have added the service account with "Make changes to events" permissions
NOTE: I tried the normal gmail account. It is working. But when I try the google business account, I have above problem(Like writer access error when setting up Google calendar event create).
I am using this code for saving a calendar event:
Please find below Screen Shot.
const jwtClient = new google.auth.JWT(
GOOGLE_CLIENT_EMAIL,
null,
GOOGLE_PRIVATE_KEY,
['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.events']
);
const calendar = google.calendar({
version: 'v3',
project: GOOGLE_PROJECT_NUMBER,
auth: jwtClient
});
var appointment_data = {
summary: 'xyz',
location: 'Location info',
description: 'Some description',
start: {
'dateTime': dataObj.appt_startdate_time,
'timeZone': dataObj.appt_timeZone,
},
end: {
'dateTime': dataObj.appt_enddate_time,
'timeZone': dataObj.appt_timeZone,
},
attendees: [
{
"displayName": 'Xyz',
"email": '[email protected]'
}
]
}
calendar.events.insert({
calendarId: GOOGLE_CALENDAR_ID,
resource: appointment_data,
}, function (err, event) {
if (err) {
console.log('There was an error contacting the Calendar service: ' + err);
return;
}
})