User Claims Change from .NET Core 1.1 to .NET Core 2.0

Hello… So my app was working smoothly in .net core 1.1, and i could get the users details as i wished. I used this code to do that:

//Get unique account number

result.UserAcctNo = user.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;

result.Name = user.Identity.Name;

result.EmailAddress = user.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value;

result.ProfileImage = user.Claims.FirstOrDefault(c => c.Type == "picture")?.Value;

Now that i have my .NET Core app running in 2.0 - everything seems to work fine - I can login with my social providers, and verify the info I want to capture is on the Auth0 dashboard.

But the issue is when I debug. I cannot find the claims from the ClaimsPrincipal like I did in .NET Core 1.1. So is there a new way to query this information? I cant find anything in the docs.

Thanks for any help.

Not using 2.0 yet, but keeping an eye on this.

You need to add the following to your ApplicationUser.cs model:

public virtual ICollection> Claims { get; } = new List>();


@grpiccoli - Thanks for the answer. Could you maybe elaborate more? Is ApplicationUser an Auth0 “recommended” model, because i made a ‘CustomerUser’ model, and this is the setup.

public class CustomUser
        public int UserId { get; set; }

        public string Email { get; set; }
        public string AccountNumberString { get; set; }
        public string FullName { get; set; }
        public string ProfileImage { get; set; }

        public virtual void Update(CustomUser cu)
            UserId = cu.UserId;
            Email = cu.Email;
            AccountNumberString = cu.AccountNumberString;
            FullName = cu.FullName;
            ProfileImage = cu.ProfileImage;

My issue is when I’m trying to copy that data from the ClaimsPrincipal, It is not showing up. But the Auth0 dashboard shows that the data is still there. So I am wondering how to query through the object to get my data. Does that make sense?

Thanks again

Edit- From the ClaimsPrincipal.cs

    // Summary:
    //     Gets a collection that contains all of the claims from all of the claims identities
    //     associated with this claims principal.
    // Returns:
    //     The claims associated with this principal.
    public virtual IEnumerable<Claim> Claims { get; }

Bump. Anyone?

Hi @boneill1292

Please see my answer to the questions here:

This shows how to get the additional claims (which are added via a rule)

Hope this helps

@boneill1292 Hi, try look into this issue:

Try to call the MapJsonKey function in order to map custom fields from userinfo endpoint in your OpenIdConnect authentication configuration in startup class