Google Calendar API in Your Application with Domain Wide delegation (when using G-suite).

Google Calendar API in Your Application with Domain Wide delegation (when using G-suite).

If you want to create a calendar events app that will use internally in your organization or in the office. Employees Schedule meetings by choosing Office, room, and date-time. The platform then Synchronizes these meetings in Google Calendar in Organizer, attendee, and meeting room-specific calendar.

For this, you need a Service Account with Domain Wide Delegation.

A service account with Domain Wide delegation grants your application to access all user's data in the organization (when using G-suite).

Enable Google Calendar API & Service Account

To setup Service account follow these steps:

  • Go to the Google APIs Console.

  • Create a new project.

  • Click Enable API. Search for and enable the Google Calendar API.

  • Create credentials for a Service account key

e1.png

  • Name the service account and grant it a Project Role of Owner.

e2.png

  • Download the JSON file or P12 for older version of google client library.

e3.png

  • Go to IAM & Admin, Service Account, find your Service account you just created above and enable Domain-wide Delegation.

How JSON File looks like

{
  "type": "service_account",
  "project_id": "your-project-id",
  "private_key_id": "some-random-string",
  "private_key": "",
  "client_email": "random-string@developer.gserviceaccount.com",
  "client_id": "radom-string.apps.googleusercontent.com",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/some-random-string.gserviceaccount.com"
}