我正在开发一个使用Google登录作为默认提供程序的C#ASP.NET MVC 5应用程序.登录功能正常,我可以获得用户的电子邮件和名称.我需要的一件事是获取用户的个人资料图片.
我怎样才能做到这一点?
到目前为止,我使用默认的MVC auth"UseGoogleAuthentication".
Microsoft.Owin.Security.Google.GoogleAuthenticationOptions a = new Microsoft.Owin.Security.Google.GoogleAuthenticationOptions();
var googleOption = new GoogleAuthenticationOptions()
{
Provider = new GoogleAuthenticationProvider()
{
OnAuthenticated = (context) =>
{
var rawUserObjectFromFacebookAsJson = context.Identity;
context.Identity.AddClaim(new Claim("urn:google:name", context.Identity.FindFirstValue(ClaimTypes.Name)));
context.Identity.AddClaim(new Claim("urn:google:email", context.Identity.FindFirstValue(ClaimTypes.Email)));
return Task.FromResult(0);
}
}
};
app.UseGoogleAuthentication(googleOption);
Run Code Online (Sandbox Code Playgroud)
这就是我如何获得电子邮件地址.但是个人资料图片怎么样?
我是否需要使用其他形式的身份验证?