Ajit Goel
Ajit Goel

Reputation: 4388

Google Authorized redirect URIs format

I am trying to integrate Google authentication with my ASP.Net core application. I have successfully integrated the appliation with Google authentication, after the login google redirects back to the home page of the application. I however would like it to redirect to https://localhost:44303/Home/dashboard.

To fix this, I have changed the "Authorized redirect URIs" from https://localhost:44303/signin-google to https://localhost:44303/Home/dashboard, but when i do that I get a redirect_uri_mismatch error. Is there a particular "Authorized redirect URIs" format that i need to follow? I checked the documentation at https://developers.google.com/identity/protocols/OAuth2WebServer but perhaps I am missing something very obvious.

OAuth Consent screen: I cannot add localhost in the "authorized domains" textbox.

enter image description here

OAuth Client Restrictions: If I add https://localhost:44303/Home/dashboard in the authorized redirect url's then I get a redirect_uri_mismatch error.

OAuth Client Restrictions Stack Trace: Error: redirect_uri_mismatch

The redirect URI in the request, https://localhost:44303/signin-google, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/685730099587-d2rac5lt7981tjkoo5td23ogm2q1at20.apps.googleusercontent.com?project=685730099587

Learn more

Request Details
response_type=code
client_id=685730099587-d2rac5lt7981tjkoo5td23ogm2q1at20.apps.googleusercontent.com
redirect_uri=https://localhost:44303/signin-google
scope=openid profile email
state=CfDJ8HG_FpcxsWVNk9Pwwx_Fh6NNjkmrebqlP7rA3Y3u0fx42o-r6KMmiNmbmC2vjIuZLqmTZMA8O8AfMgIxXO8Tj9k3x2PLe6wNyL7xqOXi6Yj-AJUmeZFwievUqEAuCKHClYJOFPAlKTxrnYIYCXoJjvwg8BM4JBKA_NgFGjy_CbGHrI2kyUC63Z7INhYHdwEyO13AsBfYXR4LfxAGf3jz3x8-ZKDUDgFOqYYKXXcDHt2VqlERXOVXdEqNUcxUtfhM

Upvotes: 2

Views: 12921

Answers (2)

hEngi
hEngi

Reputation: 915

Just run into the same problem! Just add to the Authorized Redirect URL:

https://localhost

Without any port or additional thing!

Upvotes: 2

pinoyyid
pinoyyid

Reputation: 22286

The message

The redirect URI in the request, https://localhost:44303/signin-google, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/685730099587-d2rac5lt7981tjkoo5td23ogm2q1at20.apps.googleusercontent.com?project=685730099587

tells you pretty much all you need to know. Note that you can configure multiple redirect URLs to deal with every permuatation of test, stage and production servers. Just make sure that the redirect URL your app uses is an exact string match to one of the configured URLs.

Upvotes: 1

Related Questions