---
title: Configuring Google Authentication for LobeHub
description: >-
  Learn how to configure Google SSO for LobeHub, including creating OAuth
  credentials in Google Cloud Console and setting up environment variables.
tags:
  - Google
  - Authentication
  - LobeHub
  - Single Sign-On
---

# Configuring Google Authentication

<Steps>
  ### Create Google OAuth Credentials

  1. Go to [Google Cloud Console](https://console.cloud.google.com/apis/credentials)
  2. Create a new project or select an existing one
  3. Click **Create Credentials** > **OAuth client ID**
  4. If this is your first time, configure the OAuth consent screen first (see below)
  5. Select **Web application** as the application type
  6. Add authorized redirect URIs (see callback URL configuration below)
  7. Click Create and save the **Client ID** and **Client Secret**

  ### Configure OAuth Consent Screen

  1. Go to **APIs & Services** > **OAuth consent screen**
  2. Choose user type:
     - **External**: For any Google account
     - **Internal**: For Google Workspace organization users only
  3. Fill in required information: app name, user support email, etc.
  4. Add scopes: `email` and `profile`
  5. If in testing mode, add test users

  ### Configure Callback URL

  Add to authorized redirect URIs:

  <Callout type={'info'}>
    Callback URL format:

    - Local development: `http://localhost:3210/api/auth/callback/google`
    - Production: `https://your-domain.com/api/auth/callback/google`
  </Callout>

  ### Configure Environment Variables

  | Environment Variable | Type     | Description                                                     |
  | -------------------- | -------- | --------------------------------------------------------------- |
  | `AUTH_SECRET`        | Required | Session encryption key, generate with `openssl rand -base64 32` |
  | `AUTH_SSO_PROVIDERS` | Required | Set to `google`                                                 |
  | `AUTH_GOOGLE_ID`     | Required | Client ID from Google Cloud Console                             |
  | `AUTH_GOOGLE_SECRET` | Required | Client Secret from Google Cloud Console                         |

  <Callout type={'tip'}>
    Go to [📘 Environment Variables](/docs/self-hosting/environment-variables/auth#google)
    for detailed information.
  </Callout>
</Steps>

<Callout type={'info'}>
  After successful deployment, users will be able to authenticate with Google
  and use LobeHub.
</Callout>

## Common Issues

### redirect\_uri\_mismatch Error

Ensure the callback URL configured in Google Cloud Console exactly matches your deployment address, including the protocol (http/https) and port number.

### Testing Mode Limitations

If the OAuth consent screen is in testing mode, only Google accounts added as test users can sign in.

## Related Resources

- [Google Cloud Console](https://console.cloud.google.com/)
- [Google OAuth 2.0 Documentation](https://developers.google.com/identity/protocols/oauth2)
