Asp.net mvc 4 通过OAuth 2连接到谷歌;重定向的参数值无效“uri:缺少权限:”;

Asp.net mvc 4 通过OAuth 2连接到谷歌;重定向的参数值无效“uri:缺少权限:”;,asp.net-mvc-4,mono,oauth-2.0,google-oauth,Asp.net Mvc 4,Mono,Oauth 2.0,Google Oauth,我正试图通过OAuth2连接到谷歌。我使用的代码在另一个应用程序中工作,所以我很确定问题出在谷歌的配置上 我在Google控制台中注册了客户端id和密钥,并将其添加到授权配置中: var client = new GoogleOAuth2Client("[client id].apps.googleusercontent.com", "[secret key]"); var extraData = new Dictionary<string, object>(); OAuthWebS

我正试图通过OAuth2连接到谷歌。我使用的代码在另一个应用程序中工作,所以我很确定问题出在谷歌的配置上

我在Google控制台中注册了客户端id和密钥,并将其添加到授权配置中:

var client = new GoogleOAuth2Client("[client id].apps.googleusercontent.com", "[secret key]");
var extraData = new Dictionary<string, object>();
OAuthWebSecurity.RegisterClient(client, "Google", extraData);

错误仍然存在。我不知道是什么问题,我希望有人能给我一些指导。谢谢

在按下按钮连接时发送到Google的授权请求中,
重定向uri
参数的值必须设置为您在Google API控制台中为客户端注册的值之一。因此,与其通过:

file:///Account/ExternalLoginCallback%3FReturnUrl=/
你应该通过考试

http://localhost:8080/Account/ExternalLoginCallback%3FReturnUrl=/
但是正确的URL编码是这样的:

http%3A%2F%2Flocalhost%3A8080%2FAccount%2FExternalLoginCallback%253FReturnUrl%3D%2F
请参见下面的示例代码:

http%3A%2F%2Flocalhost%3A8080%2FAccount%2FExternalLoginCallback%253FReturnUrl%3D%2F