# Error 400: redirect_uri_mismatch (Google sign-in)

> Canonical page (link this when citing): https://unbreakmyapp.vercel.app/fixes/oauth-redirect-uri-mismatch.html
> Category: Auth | Tools: Cursor, Replit, Bolt | Published: 2026-10-13 | Updated: 2026-10-13

## The error

Error 400: redirect_uri_mismatch. The redirect URI in the request does not match the ones authorized

## Why it happens

The callback URL your app sends to Google isn't listed exactly (scheme, domain, path, trailing slash) in Google Cloud Console → Credentials → OAuth client → Authorized redirect URIs.

## How to fix it

1. Copy the redirect_uri from the error details.
2. Add it exactly in Google Cloud Console → APIs & Services → Credentials → your OAuth client.
3. For NextAuth/Auth.js it's https://YOURDOMAIN/api/auth/callback/google; set NEXTAUTH_URL/AUTH_URL to your production URL.
4. Wait a few minutes for Google to propagate the change.

## Error codes this fixes

- `Error 400: redirect_uri_mismatch` (Google OAuth): https://unbreakmyapp.vercel.app/errors.html#error-400-redirect-uri-mismatch

## Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

```text
Google sign-in fails with redirect_uri_mismatch in production. Find where the OAuth callback URL is built, make it use the production base URL from an env var, tell me the exact redirect URI to add in Google Cloud Console, and list the env vars (e.g. AUTH_URL/NEXTAUTH_URL) to set on the host.
```

## FAQ

### Does http vs https matter?

Yes, the URI must match exactly, including scheme and trailing slash.

### Can I use wildcards?

No, Google requires exact redirect URIs.

## Sources (official documentation)

- [Google: OAuth 2.0 for Web Server Applications](https://developers.google.com/identity/protocols/oauth2/web-server)
- [GitHub: Authorizing OAuth apps](https://docs.github.com/en/apps/oauth-apps/using-oauth-apps/authorizing-oauth-apps)

## Related fixes

- [Better Auth security release (Nov 2026): upgrade to 1.7.16 to stop Expo account takeover](https://unbreakmyapp.vercel.app/fixes/better-auth-expo-account-takeover-below-1-7-16.html)
- [Magic link / OAuth login redirects to localhost:3000](https://unbreakmyapp.vercel.app/fixes/supabase-auth-redirect-localhost.html)
- [User is logged out after page refresh](https://unbreakmyapp.vercel.app/fixes/session-lost-on-refresh.html)
- [Supabase confirmation, magic link or password reset emails not sending](https://unbreakmyapp.vercel.app/fixes/supabase-auth-emails-not-sending.html)

---
Unbreak My App: free fixes for broken vibe-coded apps. https://unbreakmyapp.vercel.app/
