I have recently been part of a project, Building Nomi, where I was able to work on different types of integration tasks. With Building Nomi we were analyzing everyday metadata from the calendar and email to map the cooperation within organizations.
I thought I might share some of the work here. In this post, I will walk through how to set up your google workspace to be able to access email and calendar metadata through API Google API’s.
Steps:
- Create project Building Nomi on your workspace (https://console.cloud.google.com)
- Enable APIs on Project (https://console.cloud.google.com)
- Create a Service Account (https://console.cloud.google.com)
- Assign permissions (https://admin.google.com/)
Create Project for Building Nomi
Go to https://console.cloud.google.com/ and login with an administrative account.
Select Project dropdown (just right of Google Cloud Platform label). Select New Project on the form.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image.png)
Give a name to Project, e.g., BuildingNomi. Set Organization to the domain you will be accessing. Set the Location of your environment and click Create (it may take a few seconds to complete).
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-1.png)
Select and switch to the newly created Project BuildingNomi.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-2.png)
Enable API’s for Building Nomi to interact with
From the top-left menu, go to APIs & Services -> Dashboard
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-3.png)
Select ENABLE APIS AND SERVICES
*Note that this step is only to let google know that you want to use your APIS. How to authenticate and access, we’ll get to later.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-4.png)
Search and Enable the following API’s:
- Admin SDK – API will be used by Building Nomi to retrieve users and groups
- Gmail API – API will be used by Building Nomi to analyze email metadata
- Google Calendar API – API will be used by Building Nomi to analyze calendar metadata
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-5.png)
From API’s & Services dashboard, you see enabled APIs. Make sure APIs added in #7 is there.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-6.png)
Create a service account
From top-left menu go to APIs & Services -> Credentials
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-7.png)
Click CREATE CREDENTIALS and select Service account
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-8.png)
In step 1, type a Service account name, e.g., BuildingNomi. Also, type a Service account description, e.g., Service account used by Building Nomi. Now click CREATE.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-9.png)
In step 2, Select role Basic -> Viewer and click DONE (we skip step 3)
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-10.png)
From the top-left menu, go to APIs & Services -> Credentials and click the modify icon for the newly created Service Account.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-11.png)
On the Service account status section, click SHOW DOMAIN-WIDE DELEGATION and put a checkmark in Enable G Suite domain-wide delegation. Also, type a Product name for the consent screen, e.g., Building Nomi.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-12.png)
In the Keys section, click ADD KEY and then Create new key.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-13.png)
Create a private key with JSON as a Key type.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-14.png)
A key file with Service Account credentials has been created and downloaded. Store file securely.
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-15.png)
On the service account page, click SAVE
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-16.png)
From the Credentials page in section OAUTH 2.0 Client IDs, copy ClientID to clipboard (to be used in next step)
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-17.png)
Assign permissions (scopes)
Go to https://admin.google.com/ and go to Security
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-18.png)
On the Security page, scroll down to select API Controls
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-19.png)
Click MANAGE DOMAIN-WIDE DELEGATION
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-20.png)
Click Add new to add API client
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-21.png)
Paste the Client ID from the clipboard in the Client ID field. Then add the following permissions (OAuth scopes):
Building Nomi permissions/scopes | Option |
https://www.googleapis.com/auth/admin.directory.user.readonly – Used by Building Nomi to read users https://www.googleapis.com/auth/admin.directory.group.readonly – Used by Building Nomi to read groups https://www.googleapis.com/auth/admin.directory.group.member.readonly – Used by Building Nomi to read group memberships of users | Users and groups (Required) |
https://www.googleapis.com/auth/gmail.metadata – Used by Building Nomi to read Gmail metadata of users | Gmail (Optional) |
https://www.googleapis.com/auth/calendar.readonly – Used by Building Nomi to get user’s primary Google Calendar https://www.googleapis.com/auth/calendar.events.readonly – Used by Building Nomi to read metadata events from a user’s primary Google Calendar | Google Calendar (Optional) |
Instead of copy-pasting all scopes, it’s possible to insert oneliner below:
—
https://www.googleapis.com/auth/admin.directory.user.readonly,https://www.googleapis.com/auth/admin.directory.group.readonly,https://www.googleapis.com/auth/admin.directory.group.member.readonly,https://www.googleapis.com/auth/gmail.metadata,https://www.googleapis.com/auth/calendar.events.readonly,https://www.googleapis.com/auth/calendar.readonly
—
![](https://usercontent.one/wp/www.grebintegration.dk/wp-content/uploads/2021/01/image-22.png)
You are all set! 🙂