title: How to set custom error message in IdentityServer 4?
body: <p>I am trying to customise the error messages returned by IdentityServer 4. I am running a .NET Core 2.2 app. Looking in the <a href="http://docs.identityserver.io/en/latest/topics/startup.html" rel="nofollow noreferrer">docs</a> I added the following bit:</p>
  
  <pre><code>services
      .AddIdentityServer()
      // other stuff
      .AddCustomTokenRequestValidator&lt;TestValidator&gt;();
  
  ...
  
  public class TestValidator : ICustomTokenRequestValidator
  {
      public Task ValidateAsync(CustomTokenRequestValidationContextcontext)
      {
          var validationResult = context.Result;
  
          validationResult.ErrorDescription = ":D";
  
          return Task.CompletedTask;
      }
  }
  </code></pre>
  
  <p>The problem is that when I set a breakpoint in the ValidateAsync method, the breakpoint is never triggered. What I'd like to do is when a user inputs an invalid set of client id/secret to return a custom message, instead of the generic <code>error: invalid_client</code>.</p>
  
  <p>To request a token I use the following in my other project:</p>
  
  <pre><code>var token = await httpClient.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest {...});
  </code></pre>