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

# Google OAuth

> Configure Google OAuth credentials for Nudgra OSS and Nudgra Cloud.

Nudgra uses Google OAuth for dashboard sign-in. Create one web application credential in the Google Cloud Console, then set the redirect URI that matches your distribution.

## Create OAuth credentials

<Steps>
  <Step title="Open the Google Cloud Console">
    Create or select a Google Cloud project.
  </Step>

  <Step title="Create OAuth credentials">
    Create credentials for a web application.
  </Step>

  <Step title="Set the authorized origin and redirect URI">
    Use the values for your distribution below.
  </Step>

  <Step title="Copy the client ID and secret">
    Store the values in your local and production environments.
  </Step>
</Steps>

If Google asks for an authorized domain, use the root domain. For example, use `example.com` when your app is on `https://nudgra.example.com`.

## Local values

<Tabs>
  <Tab title="Nudgra OSS">
    ```text theme={null}
    Authorized JavaScript origin:
    http://localhost:3000

    Authorized redirect URI:
    http://localhost:3000/api/auth/callback/google
    ```

    Put the client ID and secret in `.env`:

    ```env theme={null}
    GOOGLE_CLIENT_ID=your-google-client-id
    GOOGLE_CLIENT_SECRET=your-google-client-secret
    ```
  </Tab>

  <Tab title="Nudgra Cloud">
    Use your local Convex site URL as the redirect URI, not the Next.js app URL.

    ```text theme={null}
    Authorized JavaScript origin:
    http://localhost:3000

    Authorized redirect URI:
    https://your-dev-deployment.convex.site/api/auth/callback/google
    ```

    Put the client ID and secret in `.env.local` or on your Convex dev deployment:

    ```env theme={null}
    AUTH_GOOGLE_ID=your-google-client-id
    AUTH_GOOGLE_SECRET=your-google-client-secret
    ```
  </Tab>
</Tabs>

## Production values

<Tabs>
  <Tab title="Nudgra OSS">
    ```text theme={null}
    Authorized JavaScript origin:
    https://your-domain.com

    Authorized redirect URI:
    https://your-domain.com/api/auth/callback/google
    ```

    Put the client ID and secret in `.env`:

    ```env theme={null}
    GOOGLE_CLIENT_ID=your-google-client-id
    GOOGLE_CLIENT_SECRET=your-google-client-secret
    ```

    Restart after changing `.env`:

    ```bash theme={null}
    docker compose up -d --build
    ```
  </Tab>

  <Tab title="Nudgra Cloud">
    ```text theme={null}
    Authorized JavaScript origin:
    https://your-app-domain.com

    Authorized redirect URI:
    https://your-convex-site.convex.site/api/auth/callback/google
    ```

    Set the values on Convex production:

    ```bash theme={null}
    npx convex env set --prod AUTH_GOOGLE_ID your-google-client-id
    npx convex env set --prod AUTH_GOOGLE_SECRET your-google-client-secret
    ```

    Redeploy after changing hosted values:

    ```bash theme={null}
    npx convex deploy --cmd "npm run build"
    ```
  </Tab>
</Tabs>

<Warning>
  For Nudgra Cloud, the Google OAuth redirect URI uses the Convex site URL. Do not use `https://your-app-domain.com/api/auth/callback/google`.
</Warning>
