# Setting up your Google's OAuth2 Credentials

## Prerequisites

* Create a [Google Cloud](https://cloud.google.com/) account

To connect your StackAI to Google services with user-provided credentials, follow these five steps:

1. [Create a Google Cloud Console project](#create-a-google-cloud-console-project).
2. [Enable the required APIs](#enable-the-required-apis).
3. [Configure the OAuth consent screen](#configure-the-oauth-consent-screen).
4. [Create Google OAuth client credentials](#create-your-google-oauth-client-credentials).
5. [Create the connection in StackAI](#create-the-connection-in-stackai).

## Create a Google Cloud Console Project

Start by creating a project in Google Cloud Console. If you already have one, you can skip ahead to the [next section](#enable-the-required-apis).

1. Log in to your [Google Cloud Console](https://console.cloud.google.com/) with your Google account.
2. In the top navigation bar, open the project dropdown and click **New Project** or go directly to the [New Project](https://console.cloud.google.com/projectcreate) page
3. Enter a **Project name** and choose a **Location**.
4. Click **Create** to generate the project.
5. Confirm that your new project is active by checking the project dropdown in the top navigation. If it’s not selected, switch to the project you just created.

<figure><img src="/files/0su0oyAnB53aYei4U4oi" alt=""><figcaption></figcaption></figure>

## Enable the required APIs

Once your project is set up, you’ll need to enable the APIs that StackAI will use:

1. Open your [Google Cloud Console - Library](https://console.cloud.google.com/apis/library), make sure you're in the correct project.
2. In the left menu, go to **APIs & Services > Library**.
3. Use the search bar to find the APIs you need. For example, if you’re connecting to Google Drive, search for and select the **Google Drive API**.
4. Select **ENABLE**.

## Configure the OAuth Consent Screen

If this is your first time using OAuth in your Google Cloud project, you'll need to [configure the OAuth consent screen](https://developers.google.com/workspace/guides/configure-oauth-consent):

1. Open your [Google Cloud Console - Library](https://console.cloud.google.com/apis/library). Make sure you're in the correct project.
2. From the left navigation menu, go to **APIs & Services > OAuth consent screen**. You’ll be redirected to the Google Auth Platform overview.
3. On the **Overview** tab, click **Get started** to begin configuring your OAuth screen.
4. Provide an **App name** and a **User support email** for the consent screen, then click **Next**.
5. For the **Audience**, select **Internal** for user access within your organization's Google workspace or **External** for any user with a Google account. Refer to Google's [User type documentation](https://support.google.com/cloud/answer/15549945?sjid=17061891731152303663-EU#user-type) for more information on user types. Select **Next** to continue.
6. Select the **email addresses** Google should use to contact you about project updates, then click **Next**.
7. Review and accept Google’s **User Data Policy**, then click **Continue** and **Create**.
8. In the left-hand menu, select **Branding**.
9. In the **Authorized domains** section, select **Add domain** and add **stack-ai.com**
10. Click **Save** to finalize your consent screen setup.<br>

## Create Google OAuth client credentials <a href="#create-your-google-oauth-client-credentials" id="create-your-google-oauth-client-credentials"></a>

Now you’ll generate the OAuth client credentials for your project:

1. Open your [Google Cloud Console](https://console.cloud.google.com/). Make sure you're in the correct project.
2. In the **APIs & Services** section in the left menu, select [**Credentials**](https://console.cloud.google.com/apis/credentials).
3. Click **+ Create credentials** > **OAuth client ID**.
4. In the **Application type** dropdown, select **Web application**.
5. Google will auto-generate a name. Update it to something meaningful so you can easily recognize it later.
6. In the **Authorized redirect URIs** field, add **<https://www.stack-ai.com/auth>** and **<https://www.stackai.com/auth>**
7. Click **Create** to generate the credentials.

## Create the connection in StackAI

With the Google project and credentials fully configured, use them in StackAI.

1. From Google's **OAuth client created** modal, copy the **Client ID** and **Client Secret**.
2. In StackAI, select to create a connection of type "OAuth Credentials" and fill your client id and secret.
3. You will be prompted to complete Google's authentication, and with that finished your connection is ready to use.

<figure><img src="/files/iwDgQ1Wi2GkMRMLHhS5o" alt=""><figcaption></figcaption></figure>

## Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

### Google hasn't verified this app <a href="#google-hasnt-verified-this-app" id="google-hasnt-verified-this-app"></a>

When using OAuth authentication, you may encounter the warning: **“Google hasn’t verified this app.”** To resolve it:

* If your app **User Type** is **Internal**, create OAuth credentials from the same account you want to authenticate.
* If your app **User Type** is **External**, you can add your email to the list of testers for the app: go to the [**Audience** ](https://console.cloud.google.com/auth/audience)page and add the email you're signing in with to the list of **Test users**.

If you need to use credentials generated by another account (by a developer or another third party), follow the instructions in [Google Cloud documentation | Authorization errors: Google hasn't verified this app](https://developers.google.com/nest/device-access/reference/errors/authorization#google_hasnt_verified_this_app).

### Google Cloud app becoming unauthorized <a href="#google-cloud-app-becoming-unauthorized" id="google-cloud-app-becoming-unauthorized"></a>

For Google Cloud apps with **Publishing status** set to **Testing** and **User type** set to **External**, consent and tokens expire after seven days. Refer to [Google Cloud Platform Console Help | Setting up your OAuth consent screen](https://support.google.com/cloud/answer/10311615?hl=en#zippy=%2Ctesting) for more information. To resolve this, select **Reconnect** in StackAI's connections dashboard in your desired connection, and set new credentials for it.&#x20;

<br>


---

# 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.stackai.com/agentic-adoption-and-security/technical-considerations/setting-up-your-googles-oauth2-credentials.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.
