title: How to get additional claims on client side in identity server 4?
body: <p>In my identity server's Startup.cs file, I have server configured as below. I am using asp.net identity for user management.</p>
  
  <pre><code>services.AddIdentityServer()
                  .AddDeveloperSigningCredential()
                  .AddInMemoryPersistedGrants()
                  .AddInMemoryIdentityResources(Config.GetIdentityResources())
                  .AddInMemoryApiResources(Config.GetApiResources())
                  .AddInMemoryClients(Config.GetClients())
                  .AddAspNetIdentity&lt;ApplicationUser&gt;();
  
  services.AddTransient&lt;IProfileService, ProfileService&gt;();
  </code></pre>
  
  <p>My <code>IdentiyResources</code> are as follow. Here I want to return extra claim as <code>IS_Token</code> which I want to use for some further business logic of my application. </p>
  
  <pre><code>public static IEnumerable&lt;IdentityResource&gt; GetIdentityResources()
          {
              return new List&lt;IdentityResource&gt;
                  {
                      new IdentityResources.OpenId(),
                      new IdentityResources.Profile(),
                      new IdentityResource("IS_token", new []{ "IS_token" } ),
                  };
          }
  </code></pre>
  
  <p>I'm also adding this claim in IssuedClaims inside my <code>IProfileService</code> as below.</p>
  
  <pre><code>public class ProfileService : IProfileService
      {
          private readonly IUserClaimsPrincipalFactory&lt;ApplicationUser&gt; _claimsFactory;
          private readonly UserManager&lt;ApplicationUser&gt; _userManager;
  
          public ProfileService(UserManager&lt;ApplicationUser&gt; userManager, IUserClaimsPrincipalFactory&lt;ApplicationUser&gt; claimsFactory)
          {
              _userManager = userManager;
              _claimsFactory = claimsFactory;
          }
  
          public async Task GetProfileDataAsync(ProfileDataRequestContext context)
          {
              var sub = context.Subject.GetSubjectId();
              var user = await _userManager.FindByIdAsync(sub);
              var principal = await _claimsFactory.CreateAsync(user);
  
              var claims = principal.Claims.ToList();
              claims = claims.Where(claim =&gt; context.RequestedClaimTypes.Contains(claim.Type)).ToList();
              claims.Add(new Claim(JwtClaimTypes.GivenName, user.UserName));
              claims.Add(new Claim(IdentityServerConstants.StandardScopes.Email, user.Email));
  
              //Get user claims from AspNetUserClaims table
              var userClaims = await _userManager.GetClaimsAsync(user);
              claims.AddRange(userClaims);
  
              context.IssuedClaims = claims;
          }
  
          public async Task IsActiveAsync(IsActiveContext context)
          {
              var sub = context.Subject.GetSubjectId();
              var user = await _userManager.FindByIdAsync(sub);
              context.IsActive = user != null;
          }
      }
  </code></pre>
  
  <p>My MVC client is configured as below</p>
  
  <pre><code>               new Client
                      {
                          ClientId = "mvc",
                          ClientName = "MVC Client",
                          AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
                          RequireConsent = false,
  
                          ClientSecrets =
                          {
                              new Secret("secret".Sha256())
                          },
  
                          // where to redirect to after login
                          RedirectUris = { "http://localhost:5002/signin-oidc" },
  
                          // where to redirect to after logout
                          PostLogoutRedirectUris = { "http://localhost:5002/signout-callback-oidc" },
  
                          AllowedScopes = new List&lt;string&gt;
                          {
                              IdentityServerConstants.StandardScopes.OpenId,
                              IdentityServerConstants.StandardScopes.Profile,
                              "IS_token",
                              "api"
                          },
  
                          AllowOfflineAccess = true
                      },
  </code></pre>
  
  <p>In my MVC application, I have the following code in <code>Startup.cs</code> file</p>
  
  <pre><code>services.AddMvc();
  
      JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
  
      services.AddAuthentication(options =&gt;
      {
          options.DefaultScheme = "Cookies";
          options.DefaultChallengeScheme = "oidc";
      })
      .AddCookie("Cookies")
      .AddOpenIdConnect("oidc", options =&gt;
      {
          options.SignInScheme = "Cookies";
          options.Authority = "http://localhost:5000";
          options.RequireHttpsMetadata = false;
  
          options.ClientId = "mvc";
          options.ClientSecret = "secret";
          options.ResponseType = "code id_token";
  
          options.SaveTokens = true;
          options.GetClaimsFromUserInfoEndpoint = true;
  
          options.Scope.Add("api");
          options.Scope.Add("offline_access");
      });
  </code></pre>
  
  <p>When I authenticate user in identity server and get back to my secured link i got following claims but IS_token is missing from my users claims.</p>
  
  <p>My secured page's <code>cshtml</code></p>
  
  <pre><code>&lt;dl&gt;
  
      @foreach (var claim in User.Claims)
  
      {
  
          &lt;dt&gt;@claim.Type&lt;/dt&gt;
  
          &lt;dd&gt;@claim.Value&lt;/dd&gt;
  
  
  
      }
  
      &lt;dt&gt;access token&lt;/dt&gt;
      &lt;dd&gt;@await ViewContext.HttpContext.GetTokenAsync("access_token")&lt;/dd&gt;
  
      &lt;dt&gt;refresh token&lt;/dt&gt;
      &lt;dd&gt;@await ViewContext.HttpContext.GetTokenAsync("refresh_token")&lt;/dd&gt;
  
  &lt;/dl&gt; 
  </code></pre>
  
  <p>This is my secured page's screenshot</p>
  
  <p><a href="https://i.stack.imgur.com/UHrFi.png" rel="nofollow noreferrer">My secure page's output</a></p>
  
  <p>As you can see in image <code>IS_token</code> is missing. How can i get <code>IS_token</code> claim???</p>