Get E-mail of User Authenticated with Microsoft Account in ASP.NET Identity

前端 未结 2 630
终归单人心
终归单人心 2021-01-04 14:32

I\'m using the ASP.NET Identity stuff that came with the new MVC 5 templates in VS2013. I\'ve configured external login providers so people can sign up using Google, Faceboo

2条回答
  •  忘掉有多难
    2021-01-04 15:10

    app.UseMicrosoftAccountAuthentication(new   MicrosoftAccountAuthenticationOptions()
            {
                ClientId = "Your_client_id",
                ClientSecret = "your_client_secret_key",
                Scope = { "wl.basic", "wl.emails" }
            });
    

    and to get email

     var externalIdentity = HttpContext.GetOwinContext().Authentication.GetExternalLoginInfoAsync();
    
    string email=externalIdentity.Result.Email;
    

提交回复
热议问题