title: Identity Server 4 create client with IConfiguration
body: <p>I stored my <a href="http://docs.identityserver.io/en/release/reference/client.html" rel="nofollow noreferrer" title="clients">clients</a> for my identity server in an appsettings.json file:</p>
  
  <pre><code>"ClientSettings":  [
  {
    "ClientId": "TestClient1",
    "RedirectUris": [ "http://localhost:5002/signin-oidc" ],
    "PostLogoutRedirectUris": [ "http://localhost:5002/signout-callback-oidc" ],
    "AllowedGrantTypes": [ "hybrid" ],
    "AllowedScopes": [ "openid","profile","email" ],
    "RequireConsent": "false",
    "Enabled": "true",
    "ClientSecrets": [
      {
        "Description": "This is the client sceret description.",
        "Value": "password123"
      }
    ]
  }
  ],
  </code></pre>
  
  <p>In my <code>ConfigureServices</code> method I setup the dependency injection</p>
  
  <pre><code>services.Configure&lt;List&lt;Client&gt;&gt;(config.GetSection("ClientSettings"));
  </code></pre>
  
  <p>My <code>IClientStore</code> gets the list of clients via dependency injection. Of course, I need to hash the client secret. To keep this question simple, I wrote this code which assumes I only have a single client with a single client secret.</p>
  
  <pre><code>public ClientConfigFileStore(IOptions&lt;List&lt;Client&gt;&gt; options)
  {
      var jsonClient = options.Value[0];
      Client client = new Client()
      {
          ClientId = jsonClient.ClientId,
          RedirectUris = jsonClient.RedirectUris,
          PostLogoutRedirectUris = jsonClient.PostLogoutRedirectUris,
          AllowedGrantTypes = jsonClient.AllowedGrantTypes,
          AllowedScopes = jsonClient.AllowedScopes,
          RequireConsent = jsonClient.RequireConsent,
          Enabled = jsonClient.Enabled,
      };//Works
      Client client = jsonClient;//Does not work
  
      client.ClientSecrets = new List&lt;Secret&gt;()
      {
          new Secret(jsonClient.ClientSecrets.First().Value.Sha256())
      };
      clients = new List&lt;Client&gt;() { client };
  }
  </code></pre>
  
  <p>Somehow I need to create a new instance of the <code>Client</code> and using the instance created by dependency injection does not work. After the user enters his credentials at the identity server the redirection back to the client fails with <code>Client secret validation failed for the client: TestClient1</code></p>
  
  <p>Why is creating a new instance necessary and is there a more elegant way to load the clients from the <code>appsettings.json</code> file?</p>