# Google OAuth 2.0 Integration

### Overview

Google OAuth is an implementation of the **OAuth 2.0 protocol** that allows applications to securely access Google services on behalf of a user without requiring their password. It’s widely used for:

* **Sign in with Google** (authentication)
* Accessing Google APIs (authorization), like Gmail, Drive, Calendar, etc.

### Why use Google OAuth?

* **Secure Authorization**
  * Apps can access Google APIs (like Gmail, Drive, Calendar) on behalf of the user without storing their credentials.
  * Uses tokens instead of passwords, reducing security risks.
* **User Convenience**
  * Enables **“Sign in with Google”**, so users don’t need to create new accounts or remember extra passwords.
* **Granular Permissions**
  * Apps request specific **scopes** (e.g., read email, view profile), and users explicitly approve them.
* **Standardized Protocol**
  * Based on **OAuth 2.0**, an industry-standard protocol for authorization, ensuring interoperability and security.
* **Improved Security**
  * Supports short-lived **access tokens** and **refresh tokens**.
  * Reduces phishing risks since passwords are never shared with third-party apps.

### **Pre-requisites:** <a href="#toc59213890" id="toc59213890"></a>

1. **An active Google Account**

You should have an active Google Account. If you do not have it, you can create an Google account at <https://console.cloud.google.com/iam-admin/serviceaccounts>

2. **An iX Hello Account**

For steps to create an account, follow the steps [here](https://docs.ixhello.com/ixhc/general/ix-hello-create-account-original)

#### Base URL, Token URL, Client email, Private Key Permissions & Authentication

Using the console ID login to you Google Account and you will be landing on the Google Cloud Page.

Lets create a new project by clicking on "Create Project".

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FgZnLQkmcUIr8n2WDyUmQ%2Fimage.png?alt=media&#x26;token=b1254fd1-6d11-4142-98c3-87c8edd3cd74" alt=""><figcaption></figcaption></figure>

Enter the Project Name and Location, then click create.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FAocDAkYakpx2GFP0mLAq%2Fimage.png?alt=media&#x26;token=da8b813a-e2e7-43da-8594-a593316176c8" alt=""><figcaption></figcaption></figure>

Now let's create a Service Account by clicking on Service Account menu and then click on option Create Service Account.

{% hint style="info" %}
A service account represents a Google Cloud service identity, such as code running on Compute Engine VMs, App Engine apps or systems running outside Google. [Learn more about service accounts. ](https://cloud.google.com/iam/help/service-accounts/overview?authuser=1\&hl=en_GB)

Organisation policies can be used to secure service accounts and block risky service account features, such as automatic IAM Grants, key creation/upload or the creation of service accounts entirely. [Learn more about service account organisation policies. ](https://cloud.google.com/resource-manager/docs/organization-policy/restricting-service-accounts?authuser=1\&hl=en_GB)
{% endhint %}

Fill in the necessary options:

| &#xD;Service account name | Demo                                                                                                                                                                                            |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| &#xD;Service account ID   | This is shown to users when they're asked to demo-531                                                                                                                                           |
| Email ID                  | <demo-531@ix-hello-test.iam.gserviceaccount.com>                                                                                                                                                |
| Click                     | on Create and Continue                                                                                                                                                                          |
| Role                      | By default, you don't need to assign any role. You can add it later if necessary. Additionally, to test Vertex AI, you might need to add a Vertex AI user role, or you can choose an Owner role |
| Click                     | Continue and Click Done                                                                                                                                                                         |

{% hint style="info" %}
**Vertex AI** is Google Cloud’s **machine learning platform** designed to help developers and data scientists build, deploy, and scale ML models efficiently. It brings together all Google Cloud AI tools under one unified environment.

* Simplifies the **end-to-end ML workflow**: data preparation, training, deployment, and monitoring.
* Provides **managed infrastructure** for training and serving models.
* Enables **custom models** and **pre-trained models** for tasks like vision, NLP, and tabular data.
  {% endhint %}

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FJqSLCjkfNXRtOwH6dpn9%2Fimage.png?alt=media&#x26;token=a8bbfb36-d8b7-43d7-bb91-341b21534d09" alt=""><figcaption></figcaption></figure>

Click on the service account to view the account details.&#x20;

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FpyyLTa5sE60msusDKHHg%2Fimage.png?alt=media&#x26;token=3e2e9717-0cc9-4321-a600-2fc2fae9dfd8" alt="" width="563"><figcaption></figcaption></figure>

Then, select the "Keys" option. In the "Add Keys" dropdown, choose "Create new key" to generate a new key, or select "Update existing" to modify the current keys.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FRSBfLIpnEdJQX1QolVrL%2Fimage.png?alt=media&#x26;token=88e15c9a-9d55-4f49-8833-656f6b985f19" alt=""><figcaption></figcaption></figure>

When you click on "Create new Key", you will see a pop up asking you to choose between two formats, JSON and P12. Choose JSON and click create, the JSON file will be downloaded. Which is the Private Key and it's used while establishing the connection between the google and ixHello.

#### Sample attached:

```
{
  "type": "service_account",
  "project_id": "ix-hello-test",
  "private_key_id": "1a5d------------------------------",
  "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCnzvhFHkwTdtca\nFklagLWT22hMqJuIXM5TctL3ac6fhzN7lZN24XGfba0QnpeTuu10gaEyeiFmG2HM\nuq5vcDWABNuHW4kj4mSQhUYs+NOauCUYif8EzQ070wm48RKl9BYvIxXIO3ZnW0AV\nKml4jVCwTD+a1zWAH9LQGMTKc4FYks6m4AM0nioGpN+b9ODRUd6i52B+N611GwHw\nmiHqKfAqJuUrpAiYyI4VqY9wpQIV6dWCvwyurFnnZxaPiqP3NaS5fWQHhosHMymH\nsDHnh8sjM6j6Aak9aK4qX8lmbWlaXxhf7LGVjoLnuq5r/ddmK93nw5hIZE9zLdlO\naXIGPCj/AgMBAAECggEAHdDf+wP1l3XDpW51TR/WY3WWFBzXOcTnohsiUfSaUm0G\n4DwE7hgDhMTLfcr3+rc5bryDpEDgA1D1MRewW7uPvfXe/a9tcBNPNACCJgZ2LqTu\nbmxChBtc8Ra/wP0Qh60Vbf2p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rQ60ElLq4Ft6LmmBdBQA2s\nHhcSjFEAGkxK59zFOzB+ymI=\n-----END PRIVATE KEY-----\n",
  "client_email": "demo-531@ix------------------------------",
  "client_id": "107-----------------------",
  "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/demo-531%40ix-hello-test.iam.gserviceaccount.com",
  "universe_domain": "googleapis.com"
}
```

### Enable the API's and Services

To enable APIs and services in Google Cloud:

1. Click the **Navigation Menu**.
2. Hover over **APIs and Services**.
3. Select **Enable APIs and Services**.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FOGL5uLU9pSpBeVjzsEsk%2Fimage.png?alt=media&#x26;token=90c3e6b8-f9c2-4df5-abbf-bb980c0967f5" alt="" width="563"><figcaption></figcaption></figure>

To enable a Google product, follow these steps:

1. Use the search bar to find your desired product, e.g., Google Calendar.
2. Click on the product.
3. Click the "Enable" button.
4. Similarly, you can enable the Vertex AI API as well

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2F8xGK7lOtpLL6GGeHNxKJ%2Fimage.png?alt=media&#x26;token=a7691a41-2e4e-466f-b6ec-769e5de696f3" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2F2ogG3EiDTC72p1cxxrjy%2Fimage.png?alt=media&#x26;token=7d2b80db-b998-4d06-9c0d-a1676b290d28" alt=""><figcaption></figcaption></figure>

### How to generate the Scope

Visit the [Google API scopes page](https://developers.google.com/identity/protocols/oauth2/scopes) to choose and implement product-specific scopes.

Select from the list of available scopes for example:

* `https://www.googleapis.com/auth/userinfo.email` → Access user email
* `https://www.googleapis.com/auth/drive` → Access Google Drive
* `https://www.googleapis.com/auth/calendar` → Access Calendar).

The most general scope for accessing Google Cloud resources is:

```
https://www.googleapis.com/auth/cloud-platform
```

**Purpose:**

* Grants **full access** to all Google Cloud services and resources that the authenticated user has permission for.
* Often used when your app needs broad access across multiple GCP services.

### Generate Base URL: Google Calendar&#x20;

{% hint style="info" %}
Input:

You can generate URLs based on the products you've chosen to enable. In this example, we have enabled Google Calendar.
{% endhint %}

To enable the Google Calendar API, follow these steps:

1. Navigate to **API and Services**.
2. Select **Enable API's and Services**.
3. You'll be redirected to the Google Calendar screen.
4. Click on **API references**.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FyeXnK6fQHnsnWfsWo6q6%2Fimage.png?alt=media&#x26;token=4c377980-5fd2-40e3-a37a-5df0a78ccf98" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}

#### Accessing Google Calendar Events via Google Workspace

**Base URL for Google Calendar API**

* Generic Base URL: `https://www.googleapis.com/calendar/v3`
* To view iX Hello events:\
  `https://www.googleapis.com/calendar/v3/calendars/dfc32f027ab318a2c4c4c013ff4edbf972f16e15cdbeeada14a615a5ef626ae9@group.calendar.google.com`

**Steps to Obtain Calendar ID**

1. Login to Google Calendar.
2. Choose existing calendars or create a new one.
   * For a new calendar: Enter Name and Description, then click "Create Calendar".
3. Find and copy the Calendar ID.
4. Update the base URL with the Calendar ID.

**Sharing the Calendar**

* Share the calendar by adding the service account client email via calendar settings.
* This allows viewing all iX Hello events in Google Calendar.
  {% endhint %}

### **Setup connection to Google Account in iX Hello** <a href="#hlk56341408" id="hlk56341408"></a>

Using the information we have generated, let's proceed and establish the connection with iX Hello.

* Login to the iX Hello portal at <https://bots.ixhello.com>
* Click on the Studio Mode link at the top of the page:

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FDYhVr3rnWCq20e2SSjF6%2Fimage.png?alt=media&#x26;token=47d0927f-3f35-49b2-8e7f-2e961d0f0f00" alt=""><figcaption></figcaption></figure>

Browse to: **Integration** > **Connect System** as shown below. Click **Add New Connection**.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2FMrEkJ5fIUKUhcCt4Ata2%2Fimage.png?alt=media&#x26;token=92be78e7-9b22-4354-b1fa-89195ac37d4f" alt=""><figcaption></figcaption></figure>

From the dropdown list, select **Rest API** and press **Next**

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2F7XwyBXf1NDFgq9yC5e5K%2Fimage.png?alt=media&#x26;token=a26cbd34-abd7-4be7-8d89-3eefc0f347cc" alt=""><figcaption></figcaption></figure>

Fill out the Configuration screen, The table below explains each of the inputs shown on this screen.

| Input                | Information                                                                        |
| -------------------- | ---------------------------------------------------------------------------------- |
| System Instance Name | Google AI API                                                                      |
| Authorization Type   | Google OAuth 2.0                                                                   |
| Base API URL         | Sample Base URL is : <https://www.googleapis.com/calendar/v3>                      |
| Access Token URL     | Can be kept Empty                                                                  |
| Scope                | <https://www.googleapis.com/auth/calendar>                                         |
| Client email         | Email ID which will be generated while creating the Priviate Key, Explained above. |

Fill the required information and click on **Validate and Connect.** If the details are correct, the integration will be saved, and you will be redirected back to the integrations listing page.

<figure><img src="https://1107164708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8XHvUsfyTUFLvToHqD%2Fuploads%2Fo4bgLZmur5IGhWiMrRzt%2Fimage.png?alt=media&#x26;token=f43d7972-ff07-492d-8764-d045fe7b2d06" alt=""><figcaption></figcaption></figure>

**Congratulations, you have successfully integrated Google OAuth to iX Hello!**
