i am trying to implement Google OAuth into my project, and i already configured the project in the google cloud console, setup the OAuth client secrets/Id and also the redirect uri.
The problem is, when the Google login pops-up, it throws the following error:
400 redirect_uri_mismatch
And this only happens when i set the authorized redirect url, in the google cloud console, to a uri different than
https://127.0.0.1/authorize
redirect_uri_mismatch is a very common error message.
The redirect uri defiles the end point in your app where you would like the authorization to be returned to. This endpoint must be properly configured in google cloud console.
If your application sends https://127.0.0.1/authorize and that endpoint isnt configured within google cloud console there will be a miss match.
The best solution is to copy which ever miss match URL the error told you and add that in Google cloud console. Remember it must match exactly HTTP is not the same as HTTPS if there is a trailing slash you will need that as well. It must match exactly.
What you need to understand is that it works with https://127.0.0.1/authorize because that is the uri that your code is using. So dont change it.
This video will explain the cause of the error and how to fix it. Google OAuth2: How the fix redirect_uri_mismatch error. Part 2 server sided web applications.
Just remember when you release this to production you will not be allowed to have a localhost redirect uri you will need to set it at that time to the domain you are hosting it on.