# 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.](https://console.developers.google.com/)
    
* Create a new project.
    
* Click Enable API. Search for and enable the Google Calendar API.
    
* Create credentials for a Service account key
    

![e1.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606236963015/V0IbCuhWp.png align="left")

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

![e2.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606237301650/2zMAYagmM.png align="left")

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

![e3.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606237309225/r-3lpMxhR.png align="left")

* Go to IAM & Admin, Service Account, find your Service account you just created above and enable [Domain-wide Delegation.](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority)
    

How JSON File looks like

```plaintext
{
  "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"
}
```
