Trying to update a calendar event, with Googles API. It’s not working out for some reason… It’s just telling me "forbidden", and I can’t find anything on Googles error handling documentation that matches this error message.
A few important key points:
- The account running the auth has Super Admin rights
- Authorization has the scope https://www.googleapis.com/auth/calendar
- I have other "read only" API calls that work just fine.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
The data I’m trying to send:
let data = {
'start': {
dateTime: event_data.start.dateTime //This data is correct and is formatted to rfc3339
},
'end': {
'dateTime': new Date().toISOString()
}
};
return new Promise((resolve, reject) => {
xhr.onreadystatechange = (e) => {
if (xhr.readyState !== 4) {
return;
}
if (xhr.status === 200) {
resolve(JSON.parse(xhr.responseText));
} else {
console.warn('request_error');
}
};
xhr.open('PUT', 'https://www.googleapis.com/calendar/v3/calendars/'+calendar_id+'/events/'+event_id);
xhr.setRequestHeader('Authorization', 'Bearer ' + access_token);
xhr.send(JSON.stringify(data));
});
2
Answers
Okay so the problem relies with updating rights for Google Workspace accounts itself. Allowing up to 48 hours for the changes to take effect is what was necessary here, at the time of writing the post I had only waited around 12-14 hours.
Now that I've waited the up to 48 hours, it works without having to change anything with the code. I couldn't find where Google specifies how long these updates take, but it's consistent with other Google services as well that sometimes waiting up to 48 hours is actually necessary.
To summarize:
Forbiden means that the user who is currently authenticated. This being the user who created the access token you are using. Does not have permission to do what you are trying to do. So the user doesn’t have access to write to calendar_id