title: IdentityServer4 Net Core 2 not calling custom iProfileService
body: <p>I've upgraded my Identity Server project to Net Core 2 and now I am not able to get the iProfileService object to be called to add in custom user claims. It did work in Net Core 1.</p>
  <p><strong>Startup.cs ConfigureServices function</strong></p>
  <pre><code>// Add application services.
  services.AddTransient&lt;IEmailSender, AuthMessageSender&gt;();
  services.AddTransient&lt;ISmsSender, AuthMessageSender&gt;();
  services.AddTransient&lt;IProfileService, M25ProfileService&gt;();
  
  //Load certificate
  var cert = new X509Certificate2(Path.Combine(_environment.ContentRootPath, 
  &quot;m25id-cert.pfx&quot;), &quot;mypassword&quot;);
  
  services.AddIdentityServer()
          .AddSigningCredential(cert)
          .AddConfigurationStore(options =&gt;
          {
              options.ConfigureDbContext = builder =&gt;
                  builder.UseSqlServer(connectionString,
                  sql =&gt; sql.MigrationsAssembly(migrationsAssembly));
          })
          .AddOperationalStore(options =&gt;
          {
              options.ConfigureDbContext = builder =&gt;
                  builder.UseSqlServer(connectionString,
                  sql =&gt; sql.MigrationsAssembly(migrationsAssembly));
                  //options.EnableTokenCleanup = true;
                  //options.TokenCleanupInterval = 30;
          })
          .AddProfileService&lt;M25ProfileService&gt;();
          .AddAspNetIdentity&lt;ApplicationUser&gt;();
  </code></pre>
  <p><strong>M25ProfileService.cs</strong></p>
  <pre><code>public class M25ProfileService : IProfileService
  {
      public M25ProfileService(UserManager&lt;ApplicationUser&gt; userManager)
      {
          _userManager = userManager;
      }
  
      public Task GetProfileDataAsync(ProfileDataRequestContext context)
      {
          var user = _userManager.GetUserAsync(context.Subject).Result;
  
          var claims = new List&lt;Claim&gt;
          {
              new Claim(JwtClaimTypes.GivenName, user.FirstName),
              new Claim(JwtClaimTypes.FamilyName, user.LastName),
              new Claim(IdentityServerConstants.StandardScopes.Email, user.Email),
              new Claim(&quot;uid&quot;, user.Id),
              new Claim(JwtClaimTypes.ZoneInfo, user.TimeZone)
          };
          if (user.UserType != null) 
            claims.Add(new Claim(&quot;mut&quot;, ((int)user.UserType).ToString()));
          context.IssuedClaims.AddRange(claims);
          return Task.FromResult(0);
  
      }
  
      public Task IsActiveAsync(IsActiveContext context)
      {
          var user = _userManager.GetUserAsync(context.Subject).Result;
          context.IsActive = user != null;
          return Task.FromResult(0);
      }
  }
  </code></pre>
  <p>}</p>
  <p><strong>Config.cs</strong></p>
  <pre><code>public class Config
  {
      // try adding claims to id token
      public static IEnumerable&lt;IdentityResource&gt; GetIdentityResources()
      {
          var m25Profile = new IdentityResource(
              &quot;m25.profile&quot;, 
              &quot;m25 Profile&quot;, 
              new[]
              {
                  ClaimTypes.Name,
                  ClaimTypes.Email,
                  IdentityServerConstants.StandardScopes.OpenId,
                  JwtClaimTypes.GivenName,
                  JwtClaimTypes.FamilyName,
                  IdentityServerConstants.StandardScopes.Email,
                  &quot;uid&quot;,
                  JwtClaimTypes.ZoneInfo
              }
          );
  
          return new List&lt;IdentityResource&gt;
          {
              new IdentityResources.OpenId(),
              new IdentityResources.Profile(),
              new IdentityResources.Email(),
              m25Profile
          };
      }
  
      public static IEnumerable&lt;ApiResource&gt; GetApiResources()
      {
          //Try adding claims to access token
          return new List&lt;ApiResource&gt;
          {
              new ApiResource(
                  &quot;m25api&quot;,
                  &quot;message25 API&quot;,
                  new[]
                  {
                      ClaimTypes.Name,
                      ClaimTypes.Email,
                      IdentityServerConstants.StandardScopes.OpenId,
                      JwtClaimTypes.GivenName,
                      JwtClaimTypes.FamilyName,
                      IdentityServerConstants.StandardScopes.Email,
                      &quot;uid&quot;,
                      JwtClaimTypes.ZoneInfo
                  }
              )
          };
      }
  
      public static IEnumerable&lt;Client&gt; GetClients()
      {
          // client credentials client
          return new List&lt;Client&gt;
          {
              new Client
              {
                  ClientId = &quot;client&quot;,
                  ClientName = &quot;Client&quot;,
                  AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
  
                  ClientSecrets =
                  {
                      new Secret(&quot;secret&quot;.Sha256())
                  },
                  AllowedScopes = new List&lt;string&gt;
                  {
                      IdentityServerConstants.StandardScopes.OpenId,
                      IdentityServerConstants.StandardScopes.Profile,
                      IdentityServerConstants.StandardScopes.Email,
                      &quot;m25api&quot;
                  }
              },
  
              // Local Development Client
              new Client
              {
                  ClientId = &quot;m25AppDev&quot;,
                  ClientName = &quot;me25&quot;,
                  AllowedGrantTypes = GrantTypes.Implicit,
                  AllowAccessTokensViaBrowser = true,
                  RequireConsent = false,
  
                  RedirectUris = { &quot;http://localhost:4200/authorize.html&quot; },
                  PostLogoutRedirectUris = { &quot;http://localhost:4200/index.html&quot; },
                  AllowedCorsOrigins = { &quot;http://localhost:4200&quot; },
  
                  AllowedScopes =
                  {
                      IdentityServerConstants.StandardScopes.OpenId,
                      IdentityServerConstants.StandardScopes.Profile,
                      IdentityServerConstants.StandardScopes.Email,
                      JwtClaimTypes.GivenName,
                      &quot;mut&quot;,
                      &quot;m25api&quot;
                  },
                  AllowOfflineAccess = true,
  
                  IdentityTokenLifetime = 300,
                  AccessTokenLifetime = 86400
              }
          };
      }
  }
  </code></pre>
  <p>The first thing I'm trying is just to get the identity server to allow me to login and show the user claims similar to the id4 samples. When I login, the standard claims are listed but none of the custom claims. I've put break points in the M25ProfileService class but they never get hit. It seems that ID4 is never using the customer ProfileService class but I do have it in my startup.cs.</p>
  <p>I've also tried from my test JS Client and get the same results. Here's a snippet from my JS Client:</p>
  <pre><code>var config = {
      authority: &quot;http://localhost:5000&quot;,
      client_id: &quot;m25AppDev&quot;,
      redirect_uri: &quot;http://localhost:4200/authorize.html&quot;,
      response_type: &quot;id_token token&quot;,
      scope:&quot;openid profile m25api&quot;,
      post_logout_redirect_uri : &quot;http://localhost:4200/index.html&quot;
  };
  var mgr = new Oidc.UserManager(config);
  
  mgr.getUser().then(function (user) {
      if (user) {
          log(&quot;User logged in&quot;, user.profile);
          document.getElementById(&quot;accessToken&quot;).innerHTML = &quot;Bearer &quot; + user.access_token + &quot;\r\n&quot;;
      }
      else {
          log(&quot;User not logged in&quot;);
      }
  });
  
  function login() {
      mgr.signinRedirect();
  }
  </code></pre>
  <p>At this point, I'm not sure what to try. I thought if I added the claims to the id token (GetIdentityResources() function from what I understand) and even the access token (GetApiResources() function from what I understand), I'd see the claims but nothing seems to work. Please help! Thanks in advance!</p>
  <p>Also, I used to be able to get the custom claims from my client as well as from the Identity Server's own index page that renders after log</p>