0

I am trying to create an event to a calendar, but get this response:

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

This is my request:

event.setStart(new EventDateTime().setDateTime(start));
event.setEnd(new EventDateTime().setDateTime(end));
event.setCreator(new Event.Creator().setEmail("...@..dk));

calendarService.events().insert(emailId, event)
                .setOauthToken(GlobalStateController.getGrapevineToken());

I am using Google signIn which works fine, and I have no trouble retrieving events for the different calendars. I use the Google token from the GoogleSignInResponse.

Furthermore, on iOS the credentials related to my company-user can create events, so I am deducting that its not related to the calendar settings or my user in general.

I see when retrieving calendar events that my accessRole is reader which is funny cause I have these 3 credentials.

   <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />

Help is very appreciated.

Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91
Mads Gade
  • 53
  • 1
  • 6

2 Answers2

0

Based from this documentation, you may get a 403 Forbidden response if you attempt to change the main event fields ("summary", "description", "location", "start", "end", or "recurrence") which the locked flag for events indicates. From this related post, try to share the calendar from your Google Calendar account with the Service Account email that is generated in the Google API Console.

The problem was sharing my calendar. Something that I don't knew.

To allow edit your calendar events from service account, do not have enough with all steps you do in the Google Api Console, you have to give permission from your calendar configuration (Calendar configuration -> Share this calendar) to the email account specified into Google Api Console (email address).

This can be a problem if it's a business account, then you will have to contact the account administrator.

"I see when retrieving calendar events that my accessRole is reader."

Check this thread. It states that:

The web UI will only allow you to share the calendar with users from the same domain as your Google Apps account. In order to use the service account, you have to give it permission in the Apps Admin, as described here (in the step 4 the name of the option is wrong, I can't remember it exactly, but it's the 3rd link in the page).

You can also check this related SO question which might help.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
0

So the problem was that i used the emailId from the a MeetingRoom as the emailId, instead of using my own email, and adding the meetingroom as an Attendee.

Mads Gade
  • 53
  • 1
  • 6