> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getinboxzero.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google OAuth

> Configure Google OAuth credentials, scopes, and required APIs

<Tip>
  **Quick Setup with CLI:** If you have the `gcloud` CLI installed, run `inbox-zero setup-google` to automate API enabling and Pub/Sub setup. It will guide you through the OAuth steps that require manual console access.
</Tip>

Go to [Google Cloud Console](https://console.cloud.google.com/) and create a new project if necessary.

1. **Configure consent screen:**
   Go to [Credentials](https://console.cloud.google.com/apis/credentials). If the banner shows up, click it and then click `Get Started`. Follow the prompts to name your app and set your contact email.

   * **Internal** — Google Workspace only. All members of your organization can sign in without additional setup. Personal Gmail accounts cannot use Internal apps.
   * **External** — any Google account, including personal Gmail. You'll need to add yourself as a test user (see step 5 below).

   <Warning>
     If you chose **External**: since your app is unverified (normal for self-hosted), you must add yourself as a test user (see step 5 below) before you can sign in. You'll also see a "This app isn't verified" warning screen when signing in — click "Advanced" then "Go to \[app name]" to proceed.
   </Warning>

2. **Create OAuth credentials:**

   1. Click `+Create Credentials` > `OAuth Client ID`.
   2. Application Type: `Web application`.
   3. Authorized JavaScript origins: `http://localhost:3000` (replace with your domain in production)
   4. Authorized redirect URIs (replace `localhost:3000` with your domain in production):
      * `http://localhost:3000/api/auth/callback/google`
      * `http://localhost:3000/api/google/linking/callback`
      * `http://localhost:3000/api/google/calendar/callback` (optional, for calendar)
      * `http://localhost:3000/api/google/drive/callback` (optional, for Drive)
   5. Click `Create` and copy the Client ID and secret.

   <img src="https://mintcdn.com/inboxzero/TkgNTBndJyvsKR4R/images/self-hosting/google-auth/1-create-oauth-client.png?fit=max&auto=format&n=TkgNTBndJyvsKR4R&q=85&s=fbd17788fd61532239ce42b2866cf20b" alt="Create OAuth Client ID" width="2020" height="720" data-path="images/self-hosting/google-auth/1-create-oauth-client.png" />

   <img src="https://mintcdn.com/inboxzero/TkgNTBndJyvsKR4R/images/self-hosting/google-auth/2-create-oauth-client.png?fit=max&auto=format&n=TkgNTBndJyvsKR4R&q=85&s=a7a006a1a7e917a8fd6a6676e23b4544" alt="Configure Web Application" width="1748" height="2200" data-path="images/self-hosting/google-auth/2-create-oauth-client.png" />

   <img src="https://mintcdn.com/inboxzero/TkgNTBndJyvsKR4R/images/self-hosting/google-auth/3-clientid-secret.png?fit=max&auto=format&n=TkgNTBndJyvsKR4R&q=85&s=fd95d03240f4b9f1cb2bcb20e383dff9" alt="Client ID and Secret" width="1186" height="1494" data-path="images/self-hosting/google-auth/3-clientid-secret.png" />

3. **Update `.env` file:**
   * Set `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`.

4. **Update [scopes](https://console.cloud.google.com/auth/scopes):**

   1. Go to `Data Access` in the sidebar.
   2. Click `Add or remove scopes`.
   3. Manually add these scopes:
      ```
      https://www.googleapis.com/auth/userinfo.profile
      https://www.googleapis.com/auth/userinfo.email
      https://www.googleapis.com/auth/gmail.modify
      https://www.googleapis.com/auth/gmail.settings.basic
      https://www.googleapis.com/auth/contacts
      https://www.googleapis.com/auth/calendar
      https://www.googleapis.com/auth/drive.file
      ```
   4. Click `Update`, then `Save`.

   <img src="https://mintcdn.com/inboxzero/TkgNTBndJyvsKR4R/images/self-hosting/google-auth/6-add-scopes.png?fit=max&auto=format&n=TkgNTBndJyvsKR4R&q=85&s=d3775baadaecbabddb88e6797b181732" alt="Add Scopes" width="3588" height="2292" data-path="images/self-hosting/google-auth/6-add-scopes.png" />

   <img src="https://mintcdn.com/inboxzero/TkgNTBndJyvsKR4R/images/self-hosting/google-auth/7-add-scopes.png?fit=max&auto=format&n=TkgNTBndJyvsKR4R&q=85&s=cef6ca2aed6bd1b7cd3ff756088494e3" alt="Manually Add Scopes" width="1570" height="2112" data-path="images/self-hosting/google-auth/7-add-scopes.png" />

   <img src="https://mintcdn.com/inboxzero/TkgNTBndJyvsKR4R/images/self-hosting/google-auth/8-save-scopes.png?fit=max&auto=format&n=TkgNTBndJyvsKR4R&q=85&s=10e03a32997a311b8555d1ed0139129c" alt="Save Scopes" width="1838" height="768" data-path="images/self-hosting/google-auth/8-save-scopes.png" />

5. **Add yourself as a test user (External only):**

   1. Go to [Audience](https://console.cloud.google.com/auth/audience).
   2. In `Test users`, click `+Add users` and enter your email.

   <img src="https://mintcdn.com/inboxzero/TkgNTBndJyvsKR4R/images/self-hosting/google-auth/5-extenal-add-user.png?fit=max&auto=format&n=TkgNTBndJyvsKR4R&q=85&s=512dcc42d23dd58a0318d9b81f80aaff" alt="Add Test User" width="1848" height="1868" data-path="images/self-hosting/google-auth/5-extenal-add-user.png" />

   Skip this step if you chose Internal — all org members can sign in automatically.

6. **Enable required APIs:**

   * [Gmail API](https://console.cloud.google.com/apis/library/gmail.googleapis.com) (required)
   * [Google People API](https://console.cloud.google.com/marketplace/product/google/people.googleapis.com) (required)
   * [Google Calendar API](https://console.cloud.google.com/marketplace/product/google/calendar-json.googleapis.com) (optional)
   * [Google Drive API](https://console.cloud.google.com/marketplace/product/google/drive.googleapis.com) (optional)

   <img src="https://mintcdn.com/inboxzero/TkgNTBndJyvsKR4R/images/self-hosting/google-auth/9-enable-gmail-api.png?fit=max&auto=format&n=TkgNTBndJyvsKR4R&q=85&s=e4941833e84c7542f17adb885d769a08" alt="Enable Gmail API" width="1122" height="712" data-path="images/self-hosting/google-auth/9-enable-gmail-api.png" />

   <img src="https://mintcdn.com/inboxzero/TkgNTBndJyvsKR4R/images/self-hosting/google-auth/10-enable-people-api.png?fit=max&auto=format&n=TkgNTBndJyvsKR4R&q=85&s=366e8c0c101687682024b0f43a2c537e" alt="Enable People API" width="1324" height="672" data-path="images/self-hosting/google-auth/10-enable-people-api.png" />

Next step for real-time notifications: [Google PubSub](/hosting/google-pubsub)
