title: ASP.NET Core OAuth with basic auth for TokenEndpoint
body: <p>I'm trying to use ASP.Net Core 2.2 with OAuth authentication. To use OAuth I use the <code>AddOAuth</code> method in the <code>public void ConfigureServices(IServiceCollection services)</code>in Startup.cs: </p>
  
  <pre class="lang-cs prettyprint-override"><code>services.AddAuthentication(options =&gt;
  {
      options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
      options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
      options.DefaultChallengeScheme = "Provider";
  })            
  .AddCookie()
  .AddOAuth("Provider", options =&gt;
  {
      options.ClientId = Configuration["Provider:ClientId"];
      options.ClientSecret = Configuration["Provider:ClientSecret"];
      options.CallbackPath = new PathString("/callback");
  
      options.AuthorizationEndpoint = "https://api.provider.net/auth/code";
      options.TokenEndpoint = "https://api.provider.net/auth/token";
  });
  </code></pre>
  
  <p>The problem is, that when the middleware tries to get an authorization code by using the <code>TokenEndpoint</code>, I receive a HTTP 401 because the provider expects a basic authentication header at this endpoint.</p>
  
  <p>My question is, how can I tell the middleware to add a basic auth header to the TokenEndpoint request?</p>