3

I am trying to create an event either via google api in my app, or via api explorer at https://developers.google.com/google-apps/calendar/v3/reference/events/insert,

and I am getting:

{
"error": {
  "errors": [
    {
      "domain": "global",
      "reason": "forbidden",
      "message": "Forbidden"
    }
    ],
    "code": 403,
    "message": "Forbidden"
  }
}

I am administrator for the domain used, I have google apis enabled, for a sister domain everything works with all the settings I checked looking identical. moreover this seemed to stop working for the current domain within last 2 weeks. Any ideas what else I can check/what grants I need to add to what?

bazik
  • 609
  • 3
  • 18
  • [this days, me too have some problems with calendar api](http://stackoverflow.com/questions/17426715/calendar-from-apps-script-every-time-authorized-required) – JuanPablo Jul 03 '13 at 02:47
  • closing... during the past year I've seen google break its api 3 times, a bug would be introduced than fixed by them a few weeks later, just the time you need to discover and deploy a workaround. this issue is a reminder of one of these cases. – bazik May 28 '14 at 07:22

2 Answers2

2

you should send the access token with your requested url.notice that access token is send by adding it to the header authentication field.with the token type "Bearer" like string access="Bearer "+accessToken;

Tushar Thakar
  • 322
  • 2
  • 8
1

I know this question was asked years ago but I struggled for several hours today with this exact response from Google calendar for an event insert and after finding out the problem I thought I'd record it for posterity.

On https://agendarizer.com we allow people to connect to a Google calendar to synchronize meeting agendas. We have this scope setup in the OAuth consent screen:

https://www.googleapis.com/auth/calendar.events

...which the docs say should be sufficient. With this code we were constantly getting a 403 Forbidden, exactly as shown above:

val event = new Event()
val url = getAgendaUrl(agenda)
event.setSummary(agenda.title)
event.setDescription("Agenda: " + url)
event.setStart(getInstantAsDateTime(date, creator.getTimeZone))
event.setEndTimeUnspecified(true)
service.events().insert(calendar.getId, event).execute()

It turns out that setting an unspecified end time was the cause of the error. Altering the code to specify an end time got things working:

val event = new Event()
val url = getAgendaUrl(agenda)
event.setSummary(agenda.title)
event.setDescription("Agenda: " + url)
event.setStart(getInstantAsDateTime(date, creator.getTimeZone))
event.setEnd(getInstantAsDateTime(date.plus(1, ChronoUnit.HOURS), creator.getTimeZone))
service.events().insert(calendar.getId, event).execute()

(getInstantAsDateTime is a helper method that converts a java.time.Instant into a Google EventDateTime).

jsPlumb Team
  • 247
  • 1
  • 3