【发布时间】:2015-02-22 18:24:34
【问题描述】:
我正在尝试通过 OAuth2 连接到 Google。我正在使用在另一个应用程序中工作的代码,所以我很确定问题出在 Google 的配置中。
我在 Google 控制台中注册了一个客户端 ID 和密钥,并添加到了授权配置中:
var client = new GoogleOAuth2Client("[client id].apps.googleusercontent.com", "[secret key]");
var extraData = new Dictionary<string, object>();
OAuthWebSecurity.RegisterClient(client, "Google", extraData);
不幸的是,当我按下按钮进行连接时,出现以下错误:
- 这是一个错误。
错误:invalid_request
redirect_uri 的参数值无效:缺少权限:
file:///Account/ExternalLoginCallback% 3FReturnUrl=/
请求详情
scope=https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/userinfo.email
response_type=代码
redirect_uri=file:///Account/ExternalLoginCallback%3FReturnUrl=/
state=provider=google&sid=[数字] client_id=[客户端 ID].apps.googleuserconte
我已尝试将 /etc/hosts 文件中的 localhost 参数更改为其他基本 URL,并且我已添加这些位置以在 Google 控制台中重定向 URI,如下所示:
http://localhost:8080/Account/ExternalLoginCallback%3FReturnUrl=/
http://localhost.example.com:8080/Account/ExternalLoginCallback
http://localhost.example.com:8080/Account/ExternalLoginCallback%3FReturnUrl=/
错误仍然存在。我不知道问题可能是什么,我希望有人能给我一些指导。谢谢
【问题讨论】:
标签: asp.net-mvc-4 mono oauth-2.0 google-oauth