title: IConfigureOptions<T> with an AuthenticationBuilder
body: <p>I've used IConfigureOptions in the past and have a new project that I'm working on using OAuth introspection. </p>
  
  <p>I tried to set up the options pattern with a class:</p>
  
  <pre><code>    public class
          ConfigureOAuth2IntrospectionOptions : IConfigureOptions&lt;
              OAuth2IntrospectionOptions&gt;
      {
          private readonly Settings settings;
  
          public ConfigureOAuth2IntrospectionOptions(IOptions&lt;Settings&gt; options)
          {
              settings = options.Value;
          }
  
          public void Configure(OAuth2IntrospectionOptions options)
          {
              options.IntrospectionEndpoint =
                  $"{settings.IdentityServer.Authority}/connect/introspect";
              options.ClientId = ScopeNameConstants.MyClientId;
              options.ClientSecret = settings.IdentityServer.ClientSecret;
          }
      }
  </code></pre>
  
  <p>And in my startup.cs I have this code:</p>
  
  <pre><code>            services.AddAuthentication(
                      options =&gt;
                      {
                          options.DefaultAuthenticateScheme =
                              OAuth2IntrospectionDefaults.AuthenticationScheme;
                          options.DefaultChallengeScheme =
                              OAuth2IntrospectionDefaults.AuthenticationScheme;
                      })
                  .AddOAuth2Introspection();
  </code></pre>
  
  <p>I add to DI Bindings:</p>
  
  <pre><code>services.AddSingleton&lt;IConfigureOptions&lt;OAuth2IntrospectionOptions&gt;, ConfigureOAuth2IntrospectionOptions&gt;();
  
  </code></pre>
  
  <p>However, the configure method is never called in my configuration class. </p>
  
  <p>The AddOauth2Introspection method has a method with an Action parameter like this that I thought would automatically be used:</p>
  
  <pre><code>public static AuthenticationBuilder AddOAuth2Introspection(this AuthenticationBuilder builder, string authenticationScheme, Action&lt;OAuth2IntrospectionOptions&gt; configureOptions)
  </code></pre>
  
  <p>Is this possible to use by default? I want to use this pattern so that I can use constructor injection for my configuration object rather than referencing configuration directly in <code>Startup.cs</code>. </p>
  
  <p>I might also have to do encryption/decryption which would need an injected class that I don't want to make available in the ConfigureServices method.</p>
  
  <p>Edit:
  Example Swashbuckle implementation from the Microsoft Docs:</p>
  
  <p>Initial ticket:
  <a href="https://github.com/Microsoft/aspnet-api-versioning/issues/422" rel="nofollow noreferrer">https://github.com/Microsoft/aspnet-api-versioning/issues/422</a></p>
  
  <p>New example:
  <a href="https://github.com/Microsoft/aspnet-api-versioning/blob/master/samples/aspnetcore/SwaggerSample/ConfigureSwaggerOptions.cs" rel="nofollow noreferrer">https://github.com/Microsoft/aspnet-api-versioning/blob/master/samples/aspnetcore/SwaggerSample/ConfigureSwaggerOptions.cs</a></p>