What it means
In an OAuth login, the provider (Google, GitHub, Apple, Microsoft) sends the user back to a
redirect URI after they approve. The provider only accepts URIs you registered in its console. With
Supabase Auth, the redirect URI the provider sees is Supabase's callback, not your app. If
that exact URL isn't registered, Google shows Error 400: redirect_uri_mismatch and GitHub
returns “The redirect_uri MUST match the registered callback URL for this application.”
Two different URLs, two different places
| URL | Example | Register it in |
|---|---|---|
| Supabase callback (provider → Supabase) | https://<project-ref>.supabase.co/auth/v1/callback |
Google Cloud console: Authorized redirect URIs. GitHub OAuth app: Authorization callback URL. |
| Your app (Supabase → your app) | https://app.example.com/auth/callback |
Supabase: Authentication → URL Configuration → Redirect URLs. |
The classic mistake is putting https://app.example.com/auth/callback into Google. Google never
sends users there; Supabase does.
Fix, step by step
- Open the provider's page in the Supabase dashboard (Authentication → Sign In / Providers → Google). Copy the Callback URL shown there.
- Paste it exactly into the provider console. For Google: the OAuth client's Authorized redirect
URIs. Under Authorized JavaScript origins put only your site's origin, such as
https://app.example.com, with no path. - Compare character by character:
httpsvshttp, trailing slash, and the project ref. Google says changes can take 5 minutes to a few hours to apply. - If you use a Supabase custom domain, the provider sees
https://auth.example.com/auth/v1/callbackinstead. Register that one (you can keep both while you switch). - For local development with the Supabase CLI, register
http://127.0.0.1:54321/auth/v1/callbackin a separate development OAuth client.
GitHub allows one callback URL per OAuth app
A GitHub OAuth app has a single Authorization callback URL. Create one app for local development and one for production, each with its own client id and secret, and set them in the matching Supabase project or local config.
Then send users back to your app
const { error } = await supabase.auth.signInWithOAuth({
provider: 'google',
options: { redirectTo: `${window.location.origin}/auth/callback` },
});redirectTo must be on the Supabase Redirect URLs allow list. If it isn't, the login succeeds but the user lands on your Site URL instead. With the server-side (PKCE) flow, your /auth/callback route exchanges the code:
// app/auth/callback/route.ts
import { NextResponse } from 'next/server';
import { createClient } from '@/utils/supabase/server';
export async function GET(request: Request) {
const { searchParams, origin } = new URL(request.url);
const code = searchParams.get('code');
if (code) {
const supabase = await createClient();
const { error } = await supabase.auth.exchangeCodeForSession(code);
if (!error) return NextResponse.redirect(`${origin}/dashboard`);
}
return NextResponse.redirect(`${origin}/auth/error`);
}How to verify
Start the login in a private window. The provider's consent screen appears (no error page), you return through …/auth/v1/callback, and you land on /dashboard on your own domain with a session. Repeat on a Vercel preview URL if you use them: the preview pattern must be on the Supabase allow list, but nothing changes in Google.
Related guides
- Supabase “Email link is invalid or has expired” and confirmation links that open localhost
- Supabase “JWT expired” – why the token went stale and how to keep it fresh
- Supabase “Database error saving new user” – find the failing trigger and fix it
- Supabase service_role or secret key exposed in frontend code – detect, rotate, fix
More in Auth, JWT and secrets · all guides