Search code examples
google-apigoogle-calendar-apigoogle-workspaceservice-accounts

Access entire gsuite domain calendar events


I want to access the entire events existing in a calendar of a gsuite domain. I tried using domain deligation with service account and it allows me to assume a user and get all of its events but i want to fetch the entire events in a gsuite account.


Solution

  • In order to achieve your task, you should create a service account which impersonates the admin of the domain.

    Afterwards, you can retrieve the users of the domain by making use of the Admin SDK.

    GET https://admin.googleapis.com/admin/directory/v1/users
    

    Based on the list you get, you can get the events from the calendar of each user.

    GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events
    

    Where, calendarId is the email of one of the users from the domain.

    Reference