This is a follow on from my thread about a 401 error when using the Google Calendar API and OAuth2, which can be found here
This contains details of the account setup that leads onto my next question, so I wont repeat myself in this thread.
OK, so when when I call the following code to update a Calendar event I get a 403 forbidden error.
for (Event event : events.getItems())
{
event.setSummary("XXX" + event.getSummary());
Event updatedEvent = calendar.events().update(CALENDAR_ID, event.getId(), event).execute();
}
Here is the returned error message:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"message" : "Forbidden"
} ],
"message" : "Forbidden"
}
What have I tried? Well, I have re-read the (rather poor) Google documentation about Service Accounts, re-checked my API Console account settings, tried changing the code that builds the credential (this leads to other errors so is a regression on my previous thread).
In short, nothing works, so is there anything obvious I am missing?
"code": 403, "message": "The user does not have sufficient permissions for file {fileId}." To fix this error, instruct the user to contact the file's owner and request edit access. You can also check user access levels in the metadata retrieved by files.
The 403 Forbidden error appears when your server denies you permission to access a page on your site. This is mainly caused by a faulty security plugin, a corrupt . htaccess file, or incorrect file permissions on your server.
An HTTP 403 response code means that a client is forbidden from accessing a valid URL. The server understands the request, but it can't fulfill the request because of client-side issues. API Gateway APIs can return 403 responses for any of the following reasons: Issue. Response header.
In my case I had to enable the CalDAV API in the Google API console. It gives a 403 response if disabled.
I know this is an old question, but this might be helpful for someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With