title: What is a ProfileService/When is a ProfileService executed?
body: <p>I've been playing with IdentityServer4. Absolutely love it.</p>
  
  <p>I've been going through the tutorials on your site, specifically <a href="https://identityserver4.readthedocs.io/en/release/quickstarts/7_javascript_client.html" rel="nofollow noreferrer">https://identityserver4.readthedocs.io/en/release/quickstarts/7_javascript_client.html</a></p>
  
  <p>I have created a Profile Service that does the following:</p>
  
  <pre><code>public class ProfileService : IProfileService
  {
      public Task GetProfileDataAsync(ProfileDataRequestContext context)
      {
          context.IssuedClaims.Add(new Claim("test-claim", "test-value"));
          return Task.FromResult(0);
      }
  
      public Task IsActiveAsync(IsActiveContext context)
      {
          context.IsActive = true;
  
          return Task.FromResult(0);
      }
  }
  </code></pre>
  
  <p>This works great, my custom claim is visible in the log window of my JS client.</p>
  
  <p>I put a break point on it just to inspect what is in the context, and I noticed it was getting hit twice. The caller properties were <code>ClaimsProviderAccessToken</code> and <code>UserInfoEndpoint</code> respectively. Why is this?</p>
  
  <p>In my naivety I removed the <code>profile</code> scope from my js client, and in oidc-js config also removed the profile scope, and set <code>loadUserInfo: false</code> yet my <code>ProfileService</code> it is still called twice.</p>
  
  <p>If my end goal is to set claims based on parameters from a database, I really I don't want to be doing this operaion twice, do I? (Genuine question -- I don't know). A 'solution' would be to only set them on "ClaimsProviderAccessToken" but there is something telling me that there will be a reason ProfileServices get called twice and that there is some importance of it setting the claims on both runs through.</p>