How to obtain the external user email (the one authentificated by google), firstname and name in my ASP.NET MVC5 website.
Asked
Active
Viewed 403 times
1 Answers
0
Taken from my question All credit to jd4u for his answer
var email = externalIdentity.FindFirstValue(ClaimTypes.Email);
the findFirstValue method looks like this :
public static string FindFirstValue(this ClaimsIdentity identity, string claimType)
{
Claim claim = identity.FindFirst(claimType);
if (claim != null)
{
return claim.Value;
}
return null;
}
-
Getting an error that FindFirstValue method does not exist in compiler in VS2013? – PussInBoots Dec 04 '13 at 16:04
-
updated with the findfirstvalue method. its in my IdentityConfig.cs in App_Start in my project – spaceman Dec 04 '13 at 17:09
-
Oh, so this was a self-made method? Okay. – PussInBoots Dec 05 '13 at 10:11
-
@PussInBoots [FindFirstValue](http://msdn.microsoft.com/en-us/library/microsoft.aspnet.identity.identityextensions.findfirstvalue%28v=vs.111%29.aspx) is not a self-made method. It's an extension method, part of `Microsoft.AspNet.Identity.IdentityExtensions` (along with `GetUserId` and `GetUserName`.) If you are getting a *method does not exist* error, it is because you need to import Microsoft.AspNet.Identity namespace (i.e. add `using Microsoft.AspNet.Identity;` at the top of your class.) – Daniel Liuzzi Feb 23 '14 at 12:07