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

# Google OAuth Setup

> Configure Google as an OAuth 2.0 provider for SnackBase

This guide explains how to configure Google as an OAuth 2.0 provider for SnackBase.

## Prerequisites

* A Google Cloud Platform (GCP) project
* SnackBase installed and running

## Step 1: Configure OAuth Consent Screen

1. Go to the [Google Cloud Console](https://console.cloud.google.com/)
2. Navigate to **APIs & Services** > **OAuth consent screen**
3. Select **User Type** (Internal or External) and click **Create**
4. Fill in the required application information (Name, User support email, etc.)
5. Add scopes: `.../auth/userinfo.email`, `.../auth/userinfo.profile`, `openid`
6. Add test users (if External and in Testing mode)

## Step 2: Create Credentials

1. Navigate to **APIs & Services** > **Credentials**
2. Click **Create Credentials** > **OAuth client ID**
3. Select **Web application**
4. **Name**: Enter "SnackBase"
5. **Authorized redirect URIs**: Add your SnackBase callback URL
   * Format: `https://<your-domain>/api/v1/auth/oauth/google/callback`
   * For local development: `http://localhost:8000/api/v1/auth/oauth/google/callback`

## Step 3: Configure SnackBase

Copy the **Client ID** and **Client Secret** from the Google Cloud Console.

In SnackBase, configure the Google provider:

| Field           | Value                                |
| --------------- | ------------------------------------ |
| `client_id`     | Your Google Client ID                |
| `client_secret` | Your Google Client Secret            |
| `redirect_uri`  | The Redirect URI you added in Step 2 |
| `scopes`        | `openid email profile` (default)     |

## Testing

1. Save your configuration
2. Attempt to sign in via the Google button on the login page

## Troubleshooting

<Note>
  Make sure your redirect URI exactly matches what you configured in Google Cloud Console, including the protocol (http/https) and port.
</Note>

**Common Issues:**

* **redirect\_uri\_mismatch**: Ensure the redirect URI in Google Cloud Console matches exactly
* **access\_denied**: User declined the authorization request
* **invalid\_client**: Check that your client ID and secret are correct

## Related Guides

* [OAuth Overview](./oauth-overview) - Understanding the OAuth flow
* [GitHub OAuth Setup](./oauth-setup-github)
* [Microsoft OAuth Setup](./oauth-setup-microsoft)
