Google Error 400: redirect_uri_mismatch with Supabase: the exact URI to add

By AI App Medic · Updated · Supabase · Google OAuth · Lovable · Auth

The user clicks Sign in with Google, a Google page appears, and it stops with Error 400: redirect_uri_mismatch. They never reach your Lovable, Bolt or Cursor app. This is Google rejecting the callback URL in the request, before Supabase issues a session. It is not a broken button, and it is not the same problem as a login that works and then drops the user on localhost:3000.

What Google is actually checking

Your app calls supabase.auth.signInWithOAuth({ provider: "google" }). Supabase sends the browser to Google with two important values: the Client ID stored in your project, and a redirect_uri. That URI is Supabase's own callback, normally:

https://YOUR_PROJECT_REF.supabase.co/auth/v1/callback

Google will only continue if that exact string is listed under Authorized redirect URIs on the same OAuth client. Scheme, host, path and trailing slash all have to match. Your app's address, such as https://your-app.lovable.app/auth/callback or https://www.example.com, is not the value Google is looking at, so putting only that address on the list does not fix the error.

After Google accepts the callback, Supabase signs the user in and then sends them to your redirectTo URL, or to the project's Site URL if you did not pass one. That second hop is configured in Supabase, not in Google.

Step 1: copy the URI from the error, not from memory

  1. Reproduce the error and open Error details (sometimes labelled Request details) on the Google page. You should see a line like redirect_uri=https://abcd1234.supabase.co/auth/v1/callback.
  2. You can also read it from the address bar. The Google URL contains redirect_uri= in encoded form: https:// shows up as https%3A%2F%2F. Decode it once and write the plain URL down.
  3. That string, character for character, is what you will paste into Google. Do not "clean it up" by adding a trailing slash or swapping the project ref for your app domain.

Step 2: edit the client whose ID is in Supabase

In Supabase, open Authentication, then Providers, then Google, and copy the Client ID (it looks like ….apps.googleusercontent.com). In Google Cloud, open Google Auth Platform, then Clients, and open the client whose ID is identical. Check the project picker at the top of the console: it is easy to be in a different Google Cloud project than the one you used when you created the credentials.

The client type must be Web application. An iOS, Android or Chrome extension client will not accept this callback, and a second web client you created later will not help if Supabase still has the first client's ID and secret.

Step 3: add the callback under Authorized redirect URIs

On that client, under Authorized redirect URIs, add the callback shown on the Supabase Google provider page (it should match what you copied in step 1):

https://YOUR_PROJECT_REF.supabase.co/auth/v1/callback

No trailing slash. Use https. If you develop against the Supabase CLI locally, the docs use http://127.0.0.1:54321/auth/v1/callback. Google allows plain http only for localhost addresses.

If you have turned on a Supabase custom domain, Auth advertises that host as the callback once the domain is active. Add both:

https://YOUR_PROJECT_REF.supabase.co/auth/v1/callback
https://auth.example.com/auth/v1/callback

Use your real custom domain in the second line (commonly auth.example.com or api.example.com). Save the client. Google can take from a few minutes up to a few hours to apply the change, so a test that fails immediately after saving is not proof that the URI is still wrong.

Step 4: put your app URL in the two places it does belong

Your app origin goes here, not in Google's redirect URI list:

In the app, pass that return URL explicitly so it does not depend on a leftover Site URL:

await supabase.auth.signInWithOAuth({
  provider: "google",
  options: {
    redirectTo: window.location.origin + "/auth/callback",
  },
});

If you just added a custom domain, confirm the new origin is present and selected in the Redirect URLs list. A domain can be live while Google sign-in still fails because the new host was never added, or because Google still lacks the new Supabase callback from step 3. The rest of the Site URL and magic-link setup is in Supabase login redirects to localhost. DNS and certificate issues belong in Lovable custom domain not working.

If Google now succeeds but the app still shows you as logged out

The mismatch error is gone, which means the Google client is fine. Work through these next:

Prevention

When you create a new Google client, paste the callback from the Supabase provider page before you turn the provider on. When you add a production domain or a Supabase custom domain, update Google and Supabase in the same sitting. Keep preview hosts on the Redirect URLs list until you no longer use them, and keep the Client ID in Supabase and the client you edit in Google as one pair.

FAQ

Why isn't my app URL the redirect URI?

With Supabase Auth, Google sends the user back to Supabase first. Supabase exchanges the code, then sends the user to your app. Google therefore checks the Supabase callback, not https://your-app.com/auth/callback.

I added the callback and still see the error. What now?

Confirm you edited the Web application client whose Client ID is stored in Supabase, not a different client or a different Google Cloud project. Then wait: Google can take from a few minutes up to a few hours to apply a URI change. Also check for a trailing slash, http versus https, or a typo in the project ref.

Google signed me in, but my app still shows the login screen. Is that the same bug?

No. Once Google accepts the redirect URI, a leftover login problem is almost always in Supabase: the Site URL, the Redirect URLs list, or a hardcoded redirectTo. That path is covered in the localhost redirect guide linked below.

Related guides