Google Oauth 2.0 redirect_uri_mismatch - 回调时更改了端口

Google Oauth 2.0 redirect_uri_mismatch - Port changed on callback

我正在使用 Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync() 来验证 Google 帐户,问题是 Google returns 之后出现 400 错误我已经登录到我的 Google 帐户:

请求中的重定向 URI:http://localhost:40745/authorize/ 与已注册的重定向 URI 不匹配。

但是我的 mvc 应用程序在 46423 运行,并且重定向 URI 在开发控制台中设置为 http://localhost:46423/authorize/。我错过了什么?

每次调试时重定向 URI 都会更改。您应该将 http://localhost/authorize/ 添加到凭据页面中的重定向 URI 列表。