title: ASP.NET Core 2.0 Configuring Authentication with Services.Configure
body: <p>The <a href="https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?tabs=aspnetcore2x" rel="nofollow noreferrer">microsoft docs example</a> shows how to configure using <code>PostConfigurationOptions</code> but in this scenario if the configuration were to change the <a href="https://github.com/aspnet/Security/blob/dev/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs" rel="nofollow noreferrer"><code>GoogleHandler</code></a> <code>IOptionsMonitor</code> dependency will not receive the update.</p>
  
  <p>AFAIK you should be able to just configure the options but I must be doing something wrong as I get the following exception:</p>
  
  <pre><code>ArgumentException: The 'ClientId' option must be provided.
  Parameter name: ClientId
      Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions.Validate()
  </code></pre>
  
  <p>I have recreated the problem in a fresh ASP.NET Core 2.0 Web Application:</p>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>using Microsoft.AspNetCore.Authentication.Cookies;
  using Microsoft.AspNetCore.Authentication.Google;
  using Microsoft.AspNetCore.Authorization;
  using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.AspNetCore.Mvc.Authorization;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  
  namespace TestWebApplication {
      public class Startup {
          public IConfiguration Configuration { get; }
  
          public Startup(IConfiguration configuration) {
              Configuration = configuration;
          }
  
          public void ConfigureServices(IServiceCollection services) {
              services
                  .AddAuthentication(o =&gt; {
                      o.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                      o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme;
                  })
                  .AddCookie()
                  .AddGoogle()
                  .Services.Configure&lt;GoogleOptions&gt;(Configuration.GetSection("Authentication:Google"));
  
              services.AddMvc(o =&gt; {
                  o.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
              });
          }
  
          public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
              app.UseDeveloperExceptionPage()
                 .UseStaticFiles()
                 .UseMvc(routes =&gt; {
                      routes.MapRoute(
                          name: "default",
                          template: "{controller=Home}/{action=Index}/{id?}");
                  });
          }
      }
  }
  </code></pre>
  
  <p><strong>Program.cs</strong></p>
  
  <pre><code>using Microsoft.AspNetCore;
  using Microsoft.AspNetCore.Hosting;
  
  namespace TestWebApplication {
      public class Program {
          public static void Main(string[] args) {
              WebHost.CreateDefaultBuilder(args)
                  .UseStartup&lt;Startup&gt;()
                  .Build()
                  .Run();
          }
      }
  }
  </code></pre>
  
  <p><strong>appsettings.json</strong></p>
  
  <pre><code>{
      "Authentication": {
          "Google": {
              "ClientId": "xxxxxx",
              "ClientSecret": "xxxxxxx"
          }
      }
  }
  </code></pre>
  
  <p>If I use <code>services.BuildServiceProvider().GetService&lt;Microsoft.Extensions.Options.IOptionsMonitor&lt;GoogleOptions&gt;&gt;().CurrentValue.ClientId</code> the clientId is configured correctly.</p>