Google Sign In
Teenybase supports two Google sign-in flows. Both share the same Google Cloud Console setup and the same authProviders config — only the frontend wiring differs.
Pick a flow
| OAuth redirect | One Tap / SPA | |
|---|---|---|
| Best for | server-rendered apps, custom frontends with a "Continue with Google" button | single-page apps that get the credential client-side |
| Config needs | clientId + clientSecret + authCookie | clientId only |
| Token delivery | cookie set on redirect back to your app | JSON response (or cookie if authCookie is set) |
| Callback URL in Google Console | required | not needed |
| Doc | Google Sign In (Custom Frontend) | Google One Tap / SPA |
If you are not sure, start with the redirect flow.
Prerequisites
You need a table with an auth extension (the default npx teenybase create template includes one). If you started from a blank template, see the Quickstart for the auth table setup.
1. Google Cloud Console
- Go to Google Cloud Console
- Create a project (or select existing)
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Application type: Web application
- Add authorized JavaScript origins:
http://localhost:8787(local dev)- Your production URL (see tip below)
- Add authorized redirect URIs (only required for the redirect flow — One Tap does not need these):
http://localhost:8787/api/v1/table/users/auth/oauth/google/callbackhttps://{your-production-url}/api/v1/table/users/auth/oauth/google/callback
- Copy the Client ID and Client Secret
Getting your exact URLs
The callback URL is your base URL + /api/v1/table/users/auth/oauth/google/callback. Locally the base URL is http://localhost:8787. In production it is the URL npx teenybase deploy --remote prints, also saved as apiRoute in infra.jsonc.
2. Add secrets
In .dev.vars, add:
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secretThe One Tap flow does not need GOOGLE_CLIENT_SECRET — only the redirect flow does.
3. Add config
For the redirect flow (server-rendered apps, custom frontends):
export default {
// ...existing config...
authProviders: [
{
name: 'google',
clientId: '$GOOGLE_CLIENT_ID',
clientSecret: '$GOOGLE_CLIENT_SECRET',
redirectUrl: '/dashboard', // Where to send user after login
},
],
// authCookie enables cookie-based sessions. The OAuth redirect flow
// sets this cookie after login so the browser stays authenticated.
// Without it, the redirect flow has no way to deliver the token.
authCookie: { name: 'teeny_auth' },
} satisfies DatabaseSettingsFor the One Tap / SPA flow:
export default {
// ...existing config...
authProviders: [
{
name: 'google',
clientId: '$GOOGLE_CLIENT_ID',
},
],
} satisfies DatabaseSettings4. Wire up the frontend
The frontend wiring is the part that differs between the two flows. Pick one:
- Google Sign In (Custom Frontend) — link your "Continue with Google" button to the OAuth authorize endpoint and let teenybase handle the redirect
- Google One Tap / SPA — drop the Google client script into your HTML and POST the credential to teenybase
5. Deploy to production
Add the same secrets to .prod.vars:
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secretUpdate appUrl in teenybase.ts to your production frontend URL, and update redirectUrl if needed.
Deploy and upload secrets:
npx teenybase deploy --remote --yes
npx teenybase secrets --remote --uploadThe deploy prints your production URL (also saved as apiRoute in infra.jsonc). Make sure the callback URLs you registered in Google Cloud Console (step 7 above) use it.