> For the complete documentation index, see [llms.txt](https://doc.wearepatchworks.com/product-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.wearepatchworks.com/product-documentation/connectors-and-instances/patchworks-connectors/google-sheets-prebuilt-connector.md).

# Google Sheets (prebuilt connector)

## Description

**Google Sheets** is whatever you want it to be! Retrieve and update data from your sheets as needed.

## API documentation

API documentation for **Google Sheets** (used to build this connector) can be found via the link below:

{% embed url="<https://developers.google.com/sheets/api/guides/concepts>" %}

## Authentication&#x20;

When adding connector instances for **Google Sheets**, the following authentication methods are supported:

* [OAuth 2 (client credentials)](#oauth-2-authorisation-code)

### OAuth 2 (client credentials)

When a user chooses to [add a connector instance](/product-documentation/connectors-and-instances/working-with-instances/adding-an-instance.md) using **OAuth 2 (client credentials)** authentication, the credentials below are required:

<table><thead><tr><th>Credential</th><th data-type="checkbox">Required?</th><th>Notes</th></tr></thead><tbody><tr><td><code>Client ID</code></td><td>true</td><td>Follow the steps detailed <a href="#the-steps">below</a> (your <strong>client ID</strong> is generated in <em>Stage 3</em>).</td></tr><tr><td><code>Client Secret</code></td><td>true</td><td>Follow the steps detailed <a href="#the-steps">below</a> (your <strong>client secret</strong> is generated in <em>Stage 3</em>).</td></tr><tr><td><code>Refresh Token</code></td><td>true</td><td>Follow the steps detailed <a href="#the-steps">below</a> (your <strong>refresh token</strong> is generated in <em>Stage 5</em>).</td></tr></tbody></table>

## Prerequisites

* You must have a Google Workspace account that's part of an organisation.

## The steps

* [Stage 1: Create a Google APIs and services project](#stage-1-create-an-apis-and-services-project)
* [Stage 2: Configure a consent screen](#stage-2-configure-consent-screen)
* [Stage 3: Create OAuth 2.0 credentials](#stage-3-create-oauth-credentials)
* [Stage 4: Apply OAuth 2.0 credentials to your OAuth playground](#stage-4-apply-credentials-in-the-oauth-playground)
* [Stage 5: Obtain a refresh token](#stage-5-obtain-a-refresh-token)

### Stage 1: Create a Google APIs and services project

**Step 1**\
Access the [Google APIs console - APIs and Services](https://console.cloud.google.com/apis/dashboard).

**Step 2**\
If you haven't got an account already, go ahead and create one (use the Google account associated with the sheets you want to access).

**Step 3**\
Click the **create project** button.

<div align="left"><figure><img src="/files/cAURDY3uIVpXQZeO9dQO" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
If you have existing projects, this page may not be the same. If you can't see a *create project* button, click the dropdown at the top of the page to open the *select a resource* page, then click the *new project* button:

<img src="/files/22Fv9uDmR9a35O5zsQGE" alt="" data-size="original">
{% endhint %}

**Step 4**\
Enter an appropriate name for this project (leave other settings as they default) and click the **create** button:

<div align="left"><figure><img src="/files/hez1ptpQ70b1MdaLUNtl" alt="" width="563"><figcaption></figcaption></figure></div>

### Stage 2: Configure consent screen

**Step 1**\
Select  **OAuth consent screen** from the left-hand navigation menu:

<div align="left"><figure><img src="/files/CtvnYAphCt5XpEIWQzDm" alt=""><figcaption></figcaption></figure></div>

**Step 2**\
Select the **internal** radio button and then click the **create** button:

<div align="left"><figure><img src="/files/OESNfjVvDPJbcuYqNFuq" alt="" width="375"><figcaption></figcaption></figure></div>

**Step 3**\
Complete **app information**:

<div align="left"><figure><img src="/files/BM2vWkbc6wJ865eczoLU" alt="" width="563"><figcaption></figcaption></figure></div>

The only mandatory fields are:

| Field                           | Summary                                                                 |
| ------------------------------- | ----------------------------------------------------------------------- |
| App name                        | We recommend something clearly identifiable as a Patchworks integration |
| User support email              | Enter your own email address.                                           |
| Developer contact email address | Enter your own email address.                                           |

**Step 4**\
Click **save and continue**.

**Step 5**\
Click the **add or remove scopes** button:

<div align="left"><figure><img src="/files/wTBvFISB2baVeLniFf5f" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 6**\
Add the following in the **manually add scopes** section:

```
https://www.googleapis.com/auth/spreadsheets
```

...then select **add to table**:

<div align="left"><figure><img src="/files/fVzKOpzgIAJYg4D4HWKX" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 7**\
Click the **update** button at the end of the page:

<div align="left"><figure><img src="/files/Chu2FCjiY1mpqxu6f7A8" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 8**\
Check that the new scope has been added under **sensitive scopes**:

<div align="left"><figure><img src="/files/7G47surXj1tEzNTFROoj" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 9**\
Click **save and continue** at the end of the page:

<div align="left"><figure><img src="/files/GYp9BXo1jk1AlFsMVbBH" alt="" width="563"><figcaption></figcaption></figure></div>

### Stage 3: Create OAuth credentials

**Step 1**\
Select **credentials** from the left-hand navigation menu:

<div align="left"><figure><img src="/files/J3A0xGkttb33r6D7FQYE" alt=""><figcaption></figcaption></figure></div>

**Step 2**\
Click the **create credentials** button:

<div align="left"><figure><img src="/files/aGeBcSXf67EA0C4W1I1V" alt=""><figcaption></figcaption></figure></div>

**Step 3**\
Select **OAuth client ID**:

<div align="left"><figure><img src="/files/3EqAQxqtlXQwisLRqHUt" alt=""><figcaption></figcaption></figure></div>

**Step 4**\
Select **web application**:

<div align="left"><figure><img src="/files/1b6obm6nq7rgbHXw65iT" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 5**\
Enter a name for this application - we recommend something clearly identifiable as a Patchworks integration, for example `Patchworks Web Client`:

<div align="left"><figure><img src="/files/2tqvr6TY9f0Hv5BBcIUZ" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 6**\
Move down to the **authorised redirect URIs** section and click the **add URI** button:

<div align="left"><figure><img src="/files/v6ovCG4z2TRCtmG1m360" alt="" width="324"><figcaption></figcaption></figure></div>

**Step 7**\
Enter the following URI:

```
https://developers.google.com/oauthplayground
```

**Step 8**\
Click the **create** button:

<div align="left"><figure><img src="/files/WyiwcseqthAah8Ku43yW" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 9**\
Your **client ID** and client secret are displayed - copy these and add them to your password manager so they're available in the next stage (and for later use in Patchworks):

<div align="left"><figure><img src="/files/8JAooyuo3CywKrvdUHb2" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 10**\
Click **OK** to close this window.

### Stage 4: Apply credentials in the OAuth playground

**Step 1**\
In a new browser tab/window, access the following URL to access the **OAuth playground**:

```
https://developers.google.com/oauthplayground
```

**Step 2**\
In the top-right corner, click the 'cog' icon to access **OAuth 2.0 configuration**:

<div align="left"><figure><img src="/files/CowlWdtjRjqJZBPnDh8z" alt=""><figcaption></figcaption></figure></div>

**Step 3**\
At the end of the configuration page, select the **use your own OAuth credentials** checkbox:

<div align="left"><figure><img src="/files/7cocfSB3olsJR3khhdx4" alt="" width="375"><figcaption></figcaption></figure></div>

**Step 4**\
Add your **client ID** and **client secret** (created in the [previous stage](#stage-3-create-oauth-credentials)) into given fields:&#x20;

<div align="left"><figure><img src="/files/fiRQNAlCG0yNy58dneEY" alt="" width="375"><figcaption></figcaption></figure></div>

**Step 5**\
Close this window.

### Stage 5: Obtain a refresh token

**Step 1**\
Still in the **OAuth playground**, move to the end of the left panel and enter the following URL in the **input your own scopes** field:

```
https://www.googleapis.com/auth/spreadsheets
```

...then click the **authorise APIs** button:

<div align="left"><figure><img src="/files/NCeeSLrjBEQJAmOdTZty" alt=""><figcaption></figcaption></figure></div>

**Step 2**\
When prompted, log in with the same Google account that you started with in [Stage 1](#stage-1-create-an-apis-and-services-project):

<figure><img src="/files/29GSoq52aRBeKDQp3mbg" alt=""><figcaption></figcaption></figure>

...you should see confirmation that your app (in this case named *Patchworks*) has access to Google spreadsheets associated with this account:

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

**Step 3**\
Click **allow** to continue to the **OAuth 2.0 playground**.

**Step 4**\
Click the **exchange authorization code for tokens** button:

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

**Step 5**\
Copy the **refresh token** and add it to your password manager.

### Stage 6: Enable the Google Sheets API

**Step 1**\
Switch back to your [Google APIs console - APIs and Services](https://console.cloud.google.com/apis/dashboard) tab/window and select **enabled APIs and services** from the left-hand navigation menu:

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

**Step 2**\
Select **enable APIs and Services** at the top of the page:

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

**Step 3**\
Search for **Google sheets API**:

<div align="left"><figure><img src="/files/EnKb00CP1mqCk7UwpPjW" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 4**\
Click the **Google sheets API** result tile:

<div align="left"><figure><img src="/files/EpnA1wBfnaNZOjZX2yIl" alt=""><figcaption></figcaption></figure></div>

**Step 5**\
Click the **enable** button:

<div align="left"><figure><img src="/files/2ac8sJ4uYxjUXIoNZTs0" alt="" width="563"><figcaption></figcaption></figure></div>

**Step 6**\
Google Sheets setup is now complete. If you haven't done so already, you can [install the Google Sheets connector from the Patchworks marketplace](/product-documentation/connectors-and-instances/working-with-connectors/installing-a-connector.md) and then use your **client ID**, **client secret**, and **refresh token** to [add required connector instances](/product-documentation/connectors-and-instances/working-with-instances/adding-an-instance.md).
