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
- Sign in to SimpleAuth and open your app.
- Go to Settings.
- Turn Enable Google sign-in on.
- Choose Shared (fastest) for local development (uses the server’s
GOOGLE_OAUTH_SHARED_*env vars), or Your Google Cloud credentials for production. - Under Allowed redirect origins, add one origin per line, e.g.
https://myapp.comandhttp://localhost:3000. These must match the origin of theredirectUrlyou pass from your app (path can differ; origin must match). In development,http://localhost/127.0.0.1on any port is allowed even if omitted. - 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)
- In Google Cloud Console, create or select a project.
- APIs & Services → OAuth consent screen — configure the consent screen (External is fine for testing).
- APIs & Services → Credentials → Create credentials → OAuth client ID — choose Web application.
- 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, usehttp://localhost:3000/api/external/auth/oauth/google/callbackinstead. - Copy the Client ID and Client Secret.
- 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)
- Install the JS SDK in your app:
npm install @simpleauthjs/core - Add the Google feature (if you did not use the
basicpreset which already includes it):
npx @simpleauthjs/react add google-auth- 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" />- 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
| Symptom | What to check |
|---|---|
Invalid redirect URL | The origin of redirectUrl must be listed under Allowed redirect origins (or be localhost HTTP in development). |
Google sign-in is not enabled for this app | Toggle Enable Google sign-in on in Settings and save. |
Google sign-in is not configured on this server | Shared mode requires GOOGLE_OAUTH_SHARED_CLIENT_ID and GOOGLE_OAUTH_SHARED_CLIENT_SECRET on the SimpleAuth server. |
oauth_error=… query param after redirect | Read the message; common cases: expired state, invalid OAuth state cookie, or email already registered without Google verification. |
| Popup flow | Not 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.