通过Google打开auth 2.0身份验证后无效的重定向网址

时间:2012-04-28 15:03:22

标签: asp.net-mvc asp.net-mvc-3 oauth-2.0

我试图通过Google Open Auth 2.0在我的MVC 3网络应用程序中实现身份验证。我已经成功构建了URL请求URL,它看起来像这样:

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&redirect_uri=http://localhost:1291/Account/Google/&response_type=token&client_id=MY_APP_ID.apps.googleusercontent.com

我的期望是重定向到以下网址:

http://localhost:1291/Account/Google?access_token=VALUE&token_type=VALUE&expires_in=VALUE

但实际上我已经重定向到了这里:

http://localhost:1291/Account/Google#access_token=VALUE&token_type=VALUE&expires_in=VALUE

唯一的区别在于#34;#"和"?"没有问号我没有看到查询字符串参数

2 个答案:

答案 0 :(得分:1)

我尝试将“response_type”从“token”更改为“code”,“#”符号已成功替换为“?”现在我可以从查询字符串中提取“代码”。所以,这是我的错。建议将“response_type = token”与客户端js一起使用。更多细节在这里:

https://developers.google.com/accounts/docs/OAuth2Login(Javascript回复部分)

答案 1 :(得分:0)

我的应用程序中有类似的功能。我能看到的唯一区别是/中的结尾redirect_uri?尝试:

  

REDIRECT_URI = HTTP://本地主机:1291 /帐户/谷歌