title: Passing IHttpClientFactory to .NET Standard class library
body: <p>There's a really cool <code>IHttpClientFactory</code> feature in the new ASP.NET Core 2.1
  <a href="https://www.hanselman.com/blog/HttpClientFactoryForTypedHttpClientInstancesInASPNETCore21.aspx" rel="noreferrer">https://www.hanselman.com/blog/HttpClientFactoryForTypedHttpClientInstancesInASPNETCore21.aspx</a></p>
  
  <p>I'm trying to use this feature in my ASP.NET Core 2.1 Preview-2 app but I need to use the <code>HttpClient</code> in my class libraries which are in .NET Standard 2.0</p>
  
  <p>Once I perform <code>AddHttpClient</code> in <code>ConfigureServices()</code> in <code>Startup.cs</code>, how do I pass this <code>HttpClientFactory</code> or a specific named <code>HttpClient</code> to an API client I created in my .NET Standard 2.0 class library? This client pretty much handles all the API calls I make to a third party.</p>
  
  <p>Basically, I'm just trying to get the specific named <code>HttpClient</code> into my <code>thirdPartyApiClient</code>.</p>
  
  <p>Here's my code in <code>ConfigureServices()</code>:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      // Create HttpClient's
      services.AddHttpClient("Api123Client", client =&gt;
      {
           client.BaseAddress = new Uri("https://api123.com/");
           client.DefaultRequestHeaders.Add("Accept", "application/json");
      });
      services.AddHttpClient("Api4567Client", client =&gt;
      {
           client.BaseAddress = new Uri("https://api4567.com/");
           client.DefaultRequestHeaders.Add("Accept", "application/json");
      });
  }
  </code></pre>