Search code examples
c#.netoauth-2.0

Google Oauth 2.0 redirect_uri_mismatch - Port changed on callback


I'm using Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync() to authenticated a Google account, the problems is that Google returns a 400 error after I've logged into my Google account:

The redirect URI in the request: http://localhost:40745/authorize/ did not match a registered redirect URI.

But my mvc application runs at 46423, also the Redirect URI is set to http://localhost:46423/authorize/ in the dev console. What am I missing?


Solution

  • The redirect URI changes each time you debug. You should add http://localhost/authorize/ to your redirect URI list in the Credential page.