title: Asp.Net Core 3 Identity - Custom Claims not present in JWT from browser
body: <p><strong>Asp.Net Core 3.0</strong><br>
  I am using the <code>ASP.NET Core web application with Angular and Authentication</code> (Individual User Accounts) template (from Visual Studio 2019).<br>
  My intention is to add some Custom Claims in the generated <code>JWT</code> and use them in browser.<br>
  In order to do that, I have extended the <code>UserClaimsPrincipalFactory</code></p>
  
  <pre><code>public class MyCustomClaimsInjector : UserClaimsPrincipalFactory&lt;ApplicationUser&gt;
  {
      public MyCustomClaimsFactory(UserManager&lt;ApplicationUser&gt; userManager, IOptions&lt;IdentityOptions&gt; optionsAccessor) : base(userManager, optionsAccessor)
      {
      }
  
      protected override async Task&lt;ClaimsIdentity&gt; GenerateClaimsAsync(ApplicationUser user)
      {
          var id = await base.GenerateClaimsAsync(user);
          id.AddClaim(new Claim("my_claim1", "AdditionalClaim1"));
          id.AddClaim(new Claim("my_claim2", "AdditionalClaim2"));
          return id;
      }
  }
  </code></pre>
  
  <p>As well, I have registered the extension in the <code>Startup.cs</code> </p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt; options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
  
          services.AddDefaultIdentity&lt;ApplicationUser&gt;()
              .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
              .AddClaimsPrincipalFactory&lt;MyCustomClaimsFactory&gt;();
  
  
          services.AddIdentityServer()
              .AddApiAuthorization&lt;ApplicationUser, ApplicationDbContext&gt;();
  
          services.AddAuthentication()
              .AddIdentityServerJwt();
          services.AddControllersWithViews();
          services.AddRazorPages();
          // In production, the Angular files will be served from this directory
          services.AddSpaStaticFiles(configuration =&gt;
          {
              configuration.RootPath = "ClientApp/dist";
          });
      }
  </code></pre>
  
  <p>During Sign In phase, started from the SPA client, the debugger passes through <code>MyCustomClaimsFactory</code> and adds the claims to the <code>ClaimsIdentity</code> in the <code>GenerateClaimsAsync</code> method. </p>
  
  <p>But, I find strange why the JWT received in browser does not contain the Claims added by the <code>MyCustomClaimsFactory</code>. </p>
  
  <p>Is my expectation to see the Custom Claim in the JWT in browser OK ?</p>
  
  <p>Can anyone suggest the direction to dig in... Why the claims isn't present in the JWT ? </p>
  
  <p>Decoded JWT is:
  <a href="https://i.stack.imgur.com/bWvPZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bWvPZ.png" alt="enter image description here"></a></p>
  
  <p>The SPA app:
  <a href="https://i.stack.imgur.com/o54Hi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/o54Hi.png" alt="enter image description here"></a></p>