# Google Workspace

This guide walks you through enabling the **G Suite Alert Center API**, creating a **service account** and **P12 key**, delegating domain-wide access, and preparing the **deliverables** for ThreatDefence.

***

## Step 1: Enable API

1. **Enable the G Suite (Admin SDK) API**
   * Open the [Google Cloud Console](https://console.cloud.google.com).
   * Go to **APIs & Services → Library**.\
     ![APIs & Services > Library](/files/c22tWpEC1pk4szDyZAPG)
   * If no project exists, create one:
     * Click the **project dropdown** → **New Project**.
     * Provide a project **Name** and **Location**.\
       ![Create New Project](/files/Xmfexu6RwwxGu9dbCon2)
   * Select the newly created project and click **Open**.\
     \&#xNAN;*Tip: wait for the project creation notification to complete before proceeding.*
   * Search for **Admin SDK API** and click **Enable**.\
     ![Enabling Admin SDK API](/files/aVitXPczkyxFhHKR8Zo2)

***

## Step 2: Create a Service Account

1. **Open Service Accounts**
   * Click the top-left **Menu**.
   * Navigate to **IAM & Admin → Service Accounts**.\
     ![IAM & Admin > Service Accounts](/files/omLH73lmm7s33WmJusuL)
2. **Create the Service Account**
   * Click **Create Service Account** and enter a **Service account name**.\
     \&#xNAN;*(Optional) Add a description.*\
     ![Create Service Account Form](/files/aiK6zp6xpqIVgOwGY8Fl)
   * Click **Create**.
3. **Assign a Role**
   * Assign **Project Viewer** (or a more restrictive role suitable for your governance).
   * Click **Continue**.\
     ![Assign Role](/files/4FCcACmq1oODSqnKPbTe)
4. **Generate a P12 Key**
   * Open the service account and click **Manage Keys**.\
     ![Manage Keys and Generate New Key](/files/BXYDcCMVB9sy5kot6mA3)
   * Click **Add Key → Create New Key**.\
     ![Create New Key](/files/7ZBiXWVYgOvhCPPLxERj)
   * Choose key type **P12** and click **Create**.\
     ![Select P12 Key](/files/7iDIR1eqP9XzFABnYmaf)
   * **Download** the P12 file when prompted and store it securely.
   * **Private key password:** set to `notasecret`.\
     ![Private Key Password](/files/mc48A4iUK5eoxuLP22cB)
   * Record the file **path/name** for future reference, then **Close**.

***

## Step 3: Add the Service Account to G Suite (Domain-Wide Delegation)

1. **Open Admin Console**
   * Go to your G Suite **Admin console**.
   * Search for **API Controls**.\
     ![API Controls in Admin Console](/files/LsuLwgYMLtUC0ag1jAgy)
2. **Manage Domain-Wide Delegation**
   * Click **Manage Domain Wide Delegations**.\
     ![Manage Domain Wide Delegations](/files/cwt8Ws4rJXKMbneXWuCe)
   * In **Authentication**, click **Add New**.
3. **Authorize the Client**
   * In **Client ID**, enter the **OAuth 2 Client ID** of the service account\
     (found in **IAM & Admin → Service Accounts** in Cloud Console).\
     ![Client ID and OAuth Scopes](/files/iEkUdn4uVDcQiD3qYzYk)
   * In **OAuth scopes**, add:

     ```
     https://www.googleapis.com/auth/admin.reports.audit.readonly
     ```

     ![Authorize Scopes](/files/BOJ2FshLZV2O2IYg1tjP)
   * Click **Authorize**.

***

## Deliverables

Email the following to [**support@threatdefence.com**](mailto:support@threatdefence.com):

1. **P12 Key**
   * The downloaded **.p12** file (stored securely).
2. **Service Account Email Address**
   * Found under **IAM & Admin → Service Accounts** in Google Cloud Console.
3. **Administrator Email Address**
   * The admin email used when configuring domain-wide delegation.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.threatdefence.com/siem-integrations/software-as-a-service/google-workspace.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
