Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Security and hardening

Google sign-in stops with Error 400: redirect_uri_mismatch

ErrorError 400: redirect_uri_mismatch

Short answer

Google compares the redirect_uri in your request with the authorized redirect URIs of that OAuth client, character by character. Copy the redirect_uri from the error page or the request URL, then register that exact value on the same client ID. Scheme, case and trailing slash all count, and wildcards or raw IP addresses are not allowed.

  • Applies to Google OAuth 2.0 web server flow, Google Cloud Console Clients page, Nov 2026
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the failing sign-in URL and read the redirect_uri query parameter exactly as your app sent it. That string is what must be registered.

    # In the browser address bar of the Google error page, or from your app's log:
    # https://accounts.google.com/o/oauth2/v2/auth?client_id=...&redirect_uri=https%3A%2F%2Fapp.example.com%2Fauth%2Fcallback&...
    python3 -c "import urllib.parse as u,sys; print(u.unquote(sys.argv[1]))" "https%3A%2F%2Fapp.example.com%2Fauth%2Fcallback"
  2. 2Match what you see, then jump to its fix

    1. 1The redirect_uri in the request differs by scheme, case, trailing slash, port or path from every authorized URIThe value registered on the client is not exactly the value your app sendsFix
    2. 2The URI is registered, but in a different client from the one named by client_id in the requestThe request uses a client ID from another project or clientFix
    3. 3The console rejects the entry, or your app is generating http:// on a public host, a raw IP, a wildcard or a #fragmentThe URI breaks Google's rules, so it cannot be registered as writtenFix

What does the error look like?

  • Error 400: redirect_uri_mismatch
  • redirect_uri_mismatch

Cause 1 of 3

The value registered on the client is not exactly the value your app sends

1Check

Google says the scheme, case and trailing slash must all match. Compare the decoded redirect_uri from the first step with the list on the client in the Google Cloud Console.

# Console > the project > Clients > your Web application client > Authorized redirect URIs

2Fix

Add the exact value from the request to Authorized redirect URIs, or change the app's setting so it sends a value that is already registered. Do not register a pattern.

# Register this exact string (example):
https://app.example.com/auth/callback

3Verify

Start the sign-in again. Google shows the account chooser instead of the 400 page.

# Retry sign-in in a fresh browser tab

Confirmed by developers.google.com

Did this fix it?

Cause 2 of 3

The request uses a client ID from another project or client

1Check

Redirect URIs belong to one OAuth client. Staging and production often use different client IDs, and an environment variable can point the app at the wrong one.

# compare the client_id in the failing request with the client you edited
env | grep -i google_client_id

2Fix

Register the URI on the client whose client_id is in the request, or set the correct client ID and secret for that environment.

# Set GOOGLE_CLIENT_ID to the client that lists the redirect URI, then restart the app

3Verify

The authorization request now carries the client ID you edited, and sign-in succeeds.

# Check the client_id parameter of the new sign-in URL

Confirmed by developers.google.com

Did this fix it?

Cause 3 of 3

The URI breaks Google's rules, so it cannot be registered as written

1Check

Google requires https for redirect URIs, except localhost and loopback addresses. It does not allow raw IP addresses (other than localhost), wildcards, a fragment, userinfo, or path traversal. Behind a proxy, many frameworks build the redirect URI as http:// because they do not see the original scheme.

# Print the redirect URI your framework generates and look at its scheme and host

2Fix

Use a hostname with https for public sites, and for local development use http://localhost:<port>. Make the app build its URI from your public https address (trust the proxy's forwarded scheme or set an explicit base URL).

# good
https://app.example.com/auth/callback
http://localhost:8080/auth/callback
# not accepted
http://203.0.113.10/auth/callback
https://*.example.com/auth/callback

3Verify

Register the corrected value and repeat sign-in; the request's redirect_uri now equals a registered entry.

# Compare the new redirect_uri with the console list

Confirmed by developers.google.com

Did this fix it?

How do I stop it coming back?

  • Keep one OAuth client per environment and write down the redirect URI of each in the repository's README.
  • Set the redirect URI from one configuration value, not from the incoming request host.
  • Register the local development URI separately and never add wildcard-like patterns.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.