oauth-2.0google-oauthgoogle-developers-console

Google OAuth2: Redirect URI mismatch even after copying the exact path


I was integrating Google OAuth2 into my app and kept getting this error:

"Error 400: redirect_uri_mismatch"

I copied the exact URL from my browser’s search bar and pasted it into both the Authorized redirect URI and the origin field on the Google Cloud Console, Credentials.

Still, I got the error. 😕

Things I Tried:


Solution

  • What I Discovered:

    Even though my browser was showing a lock icon and the address bar said https://eco-guard-git-auth-oatulas-projects.vercel.app/auth/google, the request was actually going over http.

    The redirect URI had to be http://eco-guard-git-auth-oatulas-projects.vercel.app/auth/google, not https.

    Error message


    Solution:

    enter image description here


    TL;DR:

    If you're running locally and seeing this error, don’t trust the browser's lock icon.
    Check whether your server is actually using http or https, and make sure the redirect URI matches exactly, including the scheme.