0

I'm trying to get access to a particular recurring Google Calendar Meeting from a Service Account. The owner of the Calendar Meeting is a real user and created in their personal calendar (which can't be changed at this point). Sharing the entire Google Calendar of that user with the Service Account is not a viable solution.

Instead I've tried to just invite the Service Account to the meeting - so far so good.

However, I'm unable to retrieve that event with the Google Calendar API. Basically, I'm trying something like this:

scopes = ["https://www.googleapis.com/auth/calendar.readonly"]
google_credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIALS_FILE, scopes)

calendar_service = build("calendar", "v3", credentials=google_credentials)

events_result = calendar_service.events().list(
    # calendarId="<some-service-account>@<some-project>.iam.gserviceaccount.com",
    calendarId="primary",
    singleEvents=True,
).execute()
print(events_result)
events = events_result.get("items", [])
print(events)

Neither getting the calendar with id primary nor with the <some-service-account>@<some-project>.iam.gserviceaccount.com works.

Also getting the calendar list of the service account looks like that:

scopes = ["https://www.googleapis.com/auth/calendar.readonly"]
google_credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIALS_FILE, scopes)

calendar_service = build("calendar", "v3", credentials=google_credentials)

print(calendar_service.calendarList().list().execute())
# OUTPUTS:
# {'kind': 'calendar#calendarList', 'etag': '"<removed>"', 'nextSyncToken': '<removed>', 'items': []}

Thus, an empty items list. I'm not sure what the problem is here - or if that's not even possible. Am I missing some permissions for the Service Account?

tuxtimo
  • 2,730
  • 20
  • 29
  • Does this answer your question? [Google API Service Account. Can only see service accounts drive even with Domain Wide Delegation Access](https://stackoverflow.com/questions/60892662/google-api-service-account-can-only-see-service-accounts-drive-even-with-domain) – Rafa Guillermo Feb 03 '22 at 08:01
  • nope, it doesn't ... However, today I'm receiving two random events from the recurring event ...? – tuxtimo Feb 03 '22 at 14:33

0 Answers0