Fix “Error 400: redirect_uri_mismatch” with Google sign-in and Supabase
Updated
Error message
Error 400: redirect_uri_mismatchGoogle checks the redirect address against Authorized redirect URIs in Google Cloud Console. With Supabase, Google sends the user back to Supabase first, so the URI to add is https://<project-ref>.supabase.co/auth/v1/callback. Your own site’s address goes into Supabase’s Redirect URLs, not into Google.
Where each address belongs
- Google Cloud Console → Credentials → your OAuth client → Authorized redirect URIs:
https://<project-ref>.supabase.co/auth/v1/callback. Copy the exact value from the Google provider page in Supabase. - Authorized JavaScript origins: your site, for example
https://app.yoursite.com. - Supabase → Authentication → URL Configuration → Redirect URLs: where users land after sign-in, for example
https://app.yoursite.com/auth/callback.
If you use a custom domain for Supabase, the callback is on that domain instead, and it must match exactly, including https and no trailing slash.
Other reasons for the same error
- Client ID and secret in Supabase belong to a different OAuth client than the one you edited.
- You edited the URIs a minute ago. Google can take a few minutes to apply changes.
- Your code passes
redirectTowith an address that isn’t in Supabase’s Redirect URLs. That one ends on the Site URL rather than with a Google error, see the localhost guide.
Check that it worked
Sign in with Google in a private window on production and on a preview URL. You should land on the page from redirectTo, signed in.