SimpleAuth
Guides

Google sign-in

Enable Sign in with Google for your app using SimpleAuth — dashboard setup, BYO credentials, and React SDK.

This guide walks through Sign in with Google end-to-end: turning it on in the SimpleAuth dashboard, optionally bringing your own Google OAuth client, and adding a button in your frontend.

Part 1 — Enable in the dashboard

  1. Sign in to SimpleAuth and open your app.
  2. Go to Settings.
  3. Turn Enable Google sign-in on.
  4. Choose Shared (fastest) for local development (uses the server’s GOOGLE_OAUTH_SHARED_* env vars), or Your Google Cloud credentials for production.
  5. Under Allowed redirect origins, add one origin per line, e.g. https://myapp.com and http://localhost:3000. These must match the origin of the redirectUrl you pass from your app (path can differ; origin must match). In development, http://localhost / 127.0.0.1 on any port is allowed even if omitted.
  6. Click Save.

Redirect URL in your app

After Google redirects to SimpleAuth, SimpleAuth sets the session cookie and redirects the browser to the redirectUrl you passed when starting OAuth (must be allowed). From there, call me() or use your React session hooks as usual.

Part 2 — Bring your own Google Cloud OAuth client (BYO)

  1. In Google Cloud Console, create or select a project.
  2. APIs & Services → OAuth consent screen — configure the consent screen (External is fine for testing).
  3. APIs & Services → Credentials → Create credentials → OAuth client ID — choose Web application.
  4. Under Authorized redirect URIs, add the exact callback URL for the SimpleAuth API host, e.g.
    https://simpleauth.net/api/external/auth/oauth/google/callback
    When developing against a local SimpleAuth server, use http://localhost:3000/api/external/auth/oauth/google/callback instead.
  5. Copy the Client ID and Client Secret.
  6. In SimpleAuth Settings, select Your Google Cloud credentials, paste Client ID, paste Client Secret (first time), set Allowed redirect origins, and Save.

Part 3 — Frontend (React CLI + button)

  1. Install the JS SDK in your app: npm install @simpleauthjs/core
  2. Add the Google feature (if you did not use the basic preset which already includes it):
npx @simpleauthjs/react add google-auth
  1. Pass a post-login URL into your sign-in UI (same origin must be allowlisted):
<SignInForm googleRedirectUrl="https://myapp.com/dashboard" />

or use the button directly:

import { GoogleButton } from "@/components/simpleauth"

<GoogleButton redirectUrl="https://myapp.com/dashboard" />
  1. Or call the client from your own button:
import { createSimpleAuthClient } from "@simpleauthjs/core"

const auth = createSimpleAuthClient({ apiKey: "sa_live_…" })
auth.signInWithGoogle({ redirectUrl: "https://myapp.com/dashboard" })

Part 4 — Troubleshooting

SymptomWhat to check
Invalid redirect URLThe origin of redirectUrl must be listed under Allowed redirect origins (or be localhost HTTP in development).
Google sign-in is not enabled for this appToggle Enable Google sign-in on in Settings and save.
Google sign-in is not configured on this serverShared mode requires GOOGLE_OAUTH_SHARED_CLIENT_ID and GOOGLE_OAUTH_SHARED_CLIENT_SECRET on the SimpleAuth server.
oauth_error=… query param after redirectRead the message; common cases: expired state, invalid OAuth state cookie, or email already registered without Google verification.
Popup flowNot supported yet; use full-page redirect (signInWithGoogle / getGoogleAuthUrl).

Webhooks

SimpleAuth may enqueue webhook events such as user.signed_in_via_google, user.registered_via_google, and user.linked_google_account when your app has active webhook endpoints configured.

On this page