我正在通过Microsoft.Owin库使用OAuth2身份验证构建MVC 5应用程序,以通过谷歌(Google +)进行身份验证。我可以添加email
范围,但是我尝试添加plus.login
范围来请求用户个人资料信息(即:他们圈子中的人员)不会在响应中返回任何额外信息(User
或Identity
)。Google OAuth2使用plus.login范围检索带圈的人
根据google documentation将https://www.googleapis.com/auth/plus.login
作用域添加到身份验证请求应提供对他们圈选人员列表等社交功能的访问。但是我没有通过添加plus.login
范围来获得任何额外的索赔。
Startup.Auth.cs
var googleOptions = new GoogleOAuth2AuthenticationOptions {
ClientId = "xxx",
ClientSecret = "xxx",
Provider = new GoogleOAuth2AuthenticationProvider {
OnAuthenticated = async context => {
context.Identity.AddClaim(new Claim("Image", context.User.GetValue("image").ToString()));
// profile doesn't exist in the User object
context.Identity.AddClaim(new Claim("Profile", context.User.GetValue("profile").ToString()));
}
}
};
googleOptions.Scope.Add("https://www.googleapis.com/auth/plus.login");
googleOptions.Scope.Add("email");
app.UseGoogleAuthentication(googleOptions);
什么是去请求plus.login
范围,使我可以查看验证用户的圆圈人的正确方法?
这是正确的范围,你怎么知道它不工作? – DaImTo 2014-11-26 13:44:56
我无法在上下文中的用户对象或标识对象中的任何其他声明中找到任何其他项目。我觉得我只是想念一些东西。 – bflemi3 2014-11-26 15:12:47
可见回报列表是什么? https://developers.google.com/+/api/latest/people/list – DaImTo 2014-11-26 19:10:40