ASP.NET Core 2.0 - ArgumentException: Options.ClientId must be provided ASP.NET Core 2.0 - ArgumentException: Options.ClientId must be provided asp.net asp.net

ASP.NET Core 2.0 - ArgumentException: Options.ClientId must be provided


.AddOpenIdConnect(options => GetOpenIdConnectOptions());

Your GetOpenIdConnectOptions() helper returns a new OpenIdConnectOptions instance instead of updating the options object prepared for you by the options => ... delegate.

Fix your method to take an existing OpenIdConnectOptions value and it should work:

services.AddAuthentication()    .AddOpenIdConnect(options => SetOpenIdConnectOptions(options));private void SetOpenIdConnectOptions(OpenIdConnectOptions options){    options.ClientId = Configuration["OpenIdSettings:ClientId"];    options.ClientSecret = Configuration["OpenIdSettings:ClientSecret"];    options.Authority = Configuration["OpenIdSettings:Authority"];    options.MetadataAddress = $"{Configuration["OpenIdSettings:Authority"]}/.well-known/openid-configuration";    options.GetClaimsFromUserInfoEndpoint = true;    options.SignInScheme = "Cookies";    options.ResponseType = OpenIdConnectResponseType.IdToken;    options.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    options.Scope.Add("openid");    options.Scope.Add("profile");    options.Scope.Add("roles");}