Google sign-in fails: "Error 400: redirect_uri_mismatch"

Error 400: redirect_uri_mismatch (Google sign-in page: "Access blocked: This app's request is invalid"). Google: the redirect_uri passed in the authorization request does not match an authorized redirect URI for the OAuth client ID.

What you see

You add “Sign in with Google” to your Lovable, Bolt, v0 or Cursor app. You click the button and, instead of the account picker, Google shows:

Access blocked: This app's request is invalid

You can't sign in because this app sent an invalid request. You can try
again later, or contact the developer about this issue.
If you are a developer of this app, see error details.
Error 400: redirect_uri_mismatch

That’s the full text as quoted in a Stack Overflow question from someone whose Google sign-in worked on localhost:3000 but not in production. Often it worked in the preview and broke once you published, moved to a custom domain or switched to your own Google credentials.

Why it happens

When sign-in starts, your auth backend sends the user to Google with two values: a client_id and a redirect_uri, the address Google should send the user back to. Google’s OAuth docs say the redirect_uri “must exactly match one of the authorized redirect URIs for the OAuth 2.0 client”, and that the http or https scheme, case, and trailing slash (’/’) must all match. If it doesn’t, Google stops with redirect_uri_mismatch, which it defines as: the redirect_uri passed in the authorization request does not match an authorized redirect URI for the OAuth client ID.

So the fix is never in your React code. It’s a list in Google Cloud that is missing the exact address your backend sends. Which address that is depends on who runs your auth:

  • Your own Supabase project (most Bolt, v0 and Cursor apps, and Lovable apps connected to Supabase): Google returns to Supabase, not to your app. The Supabase Google guide says to add your Supabase project’s callback URL under Authorized redirect URIs, and your app’s URL under Authorized JavaScript origins. The callback looks like https://<project-ref>.supabase.co/auth/v1/callback.
  • Lovable’s built-in backend with “Your own credentials”: Lovable lists one redirect URI for your lovable.app address and one per custom domain. Its Google auth docs say each must be added to the OAuth client and match exactly, “including the scheme, domain, path, and trailing slash”.
  • Lovable’s built-in backend, “Managed by Lovable” (the default): Lovable runs the Google client and you don’t configure Google Cloud at all, so this error shouldn’t come from your settings.

The common ways it breaks:

  1. Your app URL is in the redirect list instead of the Supabase callback. For example https://myapp.com/auth/callback is listed, but Supabase sends https://abcd1234.supabase.co/auth/v1/callback.
  2. A one-character difference: http vs https, a trailing /, a typo in the project ref.
  3. The wrong OAuth client. You edited one client in Google Cloud, but Supabase or Lovable holds the Client ID of another one (maybe in a different Google Cloud project).
  4. You turned on a Supabase custom domain. Supabase’s custom domain docs say that once it’s active, “OAuth flows will advertise the custom domain as a callback URL”, so Google now receives https://api.yourapp.com/auth/v1/callback.
  5. You connected a custom domain in Lovable with your own credentials. Lovable adds a redirect URL for the new domain but doesn’t select it. If you select it before adding it in Google Cloud, Lovable’s docs say “Google sign-in fails with a redirect URI mismatch error”.
  6. You tried to proxy the callback through your own domain. In supabase/auth #233 a developer rewrote the supabase.co callback to their site’s domain on Vercel and got error=redirect_uri_mismatch back from the provider, because the registered callback no longer matched what was sent.

Fix it

1. Read the exact redirect_uri Google received

On the Google error page, click see error details. As the answers on that Stack Overflow question point out, it tells you exactly which redirect URI your app sent, in a line like:

redirect_uri=https://abcd1234.supabase.co/auth/v1/callback

You can also find it in the address bar of that Google page, URL-encoded (%3A is : and %2F is /). Also note the client_id there. That value, character for character, is what you need on the list.

2. Open the matching OAuth client

In Google Cloud Console go to Google Auth Platform > Clients and open the Web application client whose Client ID matches the client_id from step 1. Compare it with the Client ID saved in Supabase (Authentication > Providers > Google) or in Lovable (More > Users > Settings > Google). If they differ, you’ve been editing the wrong client.

3. Add the right URI under Authorized redirect URIs

Own Supabase project: add the callback URL exactly as shown on the Supabase Google provider page:

https://<project-ref>.supabase.co/auth/v1/callback
  • If you activated a Supabase custom domain, add https://api.yourapp.com/auth/v1/callback as well. Supabase’s docs say to add it “in addition to” the supabase.co one, ideally before activating the domain.
  • For local development with the Supabase CLI, Supabase uses http://127.0.0.1:54321/auth/v1/callback. Google’s validation rules only allow plain http for localhost; everything else must be https, and wildcards (*) aren’t allowed.

Lovable with your own credentials: copy every redirect URI Lovable lists into Google, save, then go back to Lovable, select each one you added and click Save. Lovable says it sends Google one of the URIs you select, so select only ones you’ve added in Google.

Save the client in Google.

4. Put your app’s own URL where it belongs

With Supabase, your app’s address doesn’t go in Google’s redirect list. It goes in:

  • Google, Authorized JavaScript origins: https://yourapp.com (origin only, no path). The Supabase guide also says to remove http://localhost origins once you go to production.
  • Supabase, Authentication > URL Configuration: the Site URL and your Redirect URLs. If these are wrong, Google sign-in succeeds but people land on localhost:3000. That’s a different problem, covered in Supabase redirects to localhost after deploy.

You can hand the code side to your AI builder with a prompt like “Use supabase.auth.signInWithOAuth with provider ‘google’ and redirectTo set to window.location.origin + ‘/auth/callback’. Don’t hard-code localhost.” The Google Cloud and Supabase dashboard settings above you have to change yourself.

Check it worked

  1. Open your live site in a private window (so no old session or cached page interferes).
  2. Click Sign in with Google, pick an account, and confirm you come back to your app signed in.
  3. If you use a custom domain, test on both the custom domain and the default address if both stay public.

If Google now gets past the account picker but you land on an error page in your app, the redirect list is fine and the problem has moved to the Supabase URL Configuration or your callback route.

Auth is one of the first things that breaks when an AI-built app leaves the preview. Run the free production-readiness checker on your live URL: it looks for leftover localhost addresses and secret keys in your JavaScript, and tests deep-link refreshes. If you’d rather have a person go through sign-in, redirects, Row Level Security and the rest before launch, get a written pre-launch audit.