首页 > 解决方案 > Google 授权的重定向 URI 格式

问题描述

我正在尝试将 Google 身份验证与我的 ASP.Net 核心应用程序集成。在登录 google 重定向回应用程序主页后,我已成功地将应用程序与 Google 身份验证集成。但是,我希望它重定向到https://localhost:44303/Home/dashboard.

为了解决这个问题,我将“授权的重定向 URI”从https://localhost:44303/signin-google更改为https://localhost:44303/Home/dashboard,但是当我这样做时,我得到了 redirect_uri_mismatch 错误。我需要遵循特定的“授权重定向 URI”格式吗?我检查了文档,https://developers.google.com/identity/protocols/OAuth2WebServer但也许我遗漏了一些非常明显的东西。

OAuth 同意屏幕:我无法在“授权域”文本框中添加 localhost。

在此处输入图像描述

OAuth 客户端限制:如果我添加https://localhost:44303/Home/dashboard了授权的重定向 url,那么我会收到redirect_uri_mismatch错误消息。

OAuth 客户端限制 堆栈跟踪: 错误: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

标签: asp.net-coregoogle-plusgoogle-oauthgoogle-plus-signin

解决方案


只是遇到同样的问题!只需添加到授权重定向 URL:

https://localhost

没有任何端口或其他东西!


推荐阅读