title: ASP.NET Core 2.0 - ArgumentException: Options.ClientId must be provided
body: <p>I have a .NET Core 1.1 application that I wish upgrade to .NET Core 2.0. Upon updating the target framework and all dependencies, I found that my authentication setup would not compile. I have updated to account for removed properties and deprecated/moved method calls. Ellipses used to represent code omitted for brevity.</p>
  
  <p>I now receive the following error whenever I start my application<a href="https://i.stack.imgur.com/UZBpK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UZBpK.png" alt="enter image description here"></a></p>
  
  <p>1.1 Code - Inside <code>public void Configure()</code> method of Startup.cs </p>
  
  <pre><code>app.UseCookieAuthentication(new CookieAuthenticationOptions
  {
      AuthenticationScheme = "Cookies",
      ExpireTimeSpan = TimeSpan.FromHours(12),
      SlidingExpiration = false,
      CookiePath = CookiePath,
      CookieName = "MyCookie"
  });
  
  var openIdConnectionOptions = new OpenIdConnectOptions
  {
      ClientId = Configuration["OpenIdSettings:ClientId"],
      ClientSecret = Configuration["OpenIdSettings:ClientSecret"],
      Authority = Configuration["OpenIdSettings:Authority"],
      MetadataAddress = $"{Configuration["OpenIdSettings:Authority"]}/.well-known/openid-configuration",
      GetClaimsFromUserInfoEndpoint = true,
      AuthenticationScheme = "oidc",
      SignInScheme = "Cookies",
      ResponseType = OpenIdConnectResponseType.IdToken,
      TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
      {
          // This sets the value of User.Identity.Name to users AD username
          NameClaimType = IdentityClaimTypes.WindowsAccountName,
          RoleClaimType = IdentityClaimTypes.Role,
          AuthenticationType = "Cookies",
          ValidateIssuer = false
      }
  };
  
  // Scopes needed by application
  openIdConnectionOptions.Scope.Add("openid");
  openIdConnectionOptions.Scope.Add("profile");
  openIdConnectionOptions.Scope.Add("roles");
  
  app.UseOpenIdConnectAuthentication(openIdConnectionOptions);
  </code></pre>
  
  <p>Everything I'm reading shows this process has moved to the <code>ConfigureServices</code> method. Here is my new code for Core 2.0</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      ...
  
      services.AddAuthentication(options =&gt;
      {
          options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
          options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
      }).AddCookie(options =&gt; new CookieAuthenticationOptions
      {
          //AuthenticationScheme = "Cookies", // Removed in 2.0
          ExpireTimeSpan = TimeSpan.FromHours(12),
          SlidingExpiration = false,
          Cookie = new CookieBuilder
          {
              Path = CookiePath,
              Name = "MyCookie"
          }
      }).AddOpenIdConnect(options =&gt; GetOpenIdConnectOptions());
  
      ...
  }
  
  public void Configure(IApplicationBuilder app)
  {
      ...
      app.UseAuthentication();
      ...
  }
  private OpenIdConnectOptions GetOpenIdConnectOptions()
  {
          var openIdConnectionOptions = new OpenIdConnectOptions
          {
              ClientId = Configuration["OpenIdSettings:ClientId"],
              ClientSecret = Configuration["OpenIdSettings:ClientSecret"],
              Authority = Configuration["OpenIdSettings:Authority"],
              MetadataAddress = $"{Configuration["OpenIdSettings:Authority"]}/.well-known/openid-configuration",
              GetClaimsFromUserInfoEndpoint = true,
              SignInScheme = "Cookies",
              ResponseType = OpenIdConnectResponseType.IdToken,
  
              TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
              {
                  // This sets the value of User.Identity.Name to users AD username
                  NameClaimType = IdentityClaimTypes.WindowsAccountName,
                  RoleClaimType = IdentityClaimTypes.Role,
                  AuthenticationType = "Cookies",
                  ValidateIssuer = false
              }
          };
  
          // Scopes needed by application
          openIdConnectionOptions.Scope.Add("openid");
          openIdConnectionOptions.Scope.Add("profile");
          openIdConnectionOptions.Scope.Add("roles");
  
          return openIdConnectionOptions;
      }
  </code></pre>
  
  <p>I am setting the ClientId (or so I thought) in my <code>GetOpenIdConnectOptions</code> so I am unclear on what ClientId the error is referring to.<code>enter code here</code></p>
  
  <p>Edit:
  appsettings.json</p>
  
  <pre><code>"OpenIdSettings": {
    "Authority": "https://myopenidauthenticationendpointurl",
    "ClientId": "myappname",
    "CookiePath":  "mypath"
  }
  </code></pre>