How to get external login email address in ASP.NET MVC 5

We are using the Asp.Net ID in MVC 5 to allow the user to log in with their social media accounts.

var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

      

We are using the above API to get account information, but all accounts except Facebook are blank for loginInfo.Email

how we can get the email address for these two social accounts:

  • Microsoft account
  • Twitter
+3


source to share


1 answer


I believe that none of these providers distribute the user's email as a claim. You will need to query their API directly to get the email addresses.

To get email addresses from a Microsoft account, poke the / me endpoint



Twitter does not allow you to obtain the user's email address. The advice here (as others ended up too) is to ask the user for the email address from your application.

+2


source







All Articles