1
我使用inbuild外部登錄在Asp.net網站 當用戶登錄使用谷歌一切正常,我檢索用戶名和電子郵件。Asp.net外部登錄(Facebook)不要取回電子郵件
當我從Facebook登錄,它doees無法檢索電子郵件
protected void Page_Load()
{
// Process the result from an auth provider in the request
ProviderName = IdentityHelper.GetProviderNameFromRequest(Request);
if (String.IsNullOrEmpty(ProviderName))
{
Response.Redirect("~/Account/Login");
}
if (!IsPostBack)
{
var manager = new UserManager();
var loginInfo = Context.GetOwinContext().Authentication.GetExternalLoginInfo();
if (loginInfo == null)
{
Response.Redirect("~/Account/Login");
}
var user = manager.Find(loginInfo.Login);
if (user != null)
{
IdentityHelper.SignIn(manager, user, isPersistent: false);
IdentityHelper.RedirectToReturnUrl("~/clients", Response);
}
else if (User.Identity.IsAuthenticated)
{
// Apply Xsrf check when linking
var verifiedloginInfo = Context.GetOwinContext().Authentication.GetExternalLoginInfo(IdentityHelper.XsrfKey, User.Identity.GetUserId());
if (verifiedloginInfo == null)
{
Response.Redirect("~/Account/Login");
}
var result = manager.AddLogin(User.Identity.GetUserId(), verifiedloginInfo.Login);
if (result.Succeeded)
{
IdentityHelper.RedirectToReturnUrl("~/clients", Response);
}
else
{
AddErrors(result);
return;
}
}
else
{
userName.Text = loginInfo.DefaultUserName;
Email.Text = loginInfo.Email ;
}
}
}
請幫助