.AddOpenIdConnect(o =>
{
o.RequireHttpsMetadata = _options.Sso.RequireHttpsMetadata;
o.Authority = _options.Sso.Authority;
o.ClientId = _options.Sso.ClientId;
o.ClientSecret = _options.Sso.ClientSecret;
o.ResponseType = OpenIdConnectResponseType.CodeIdToken;
o.GetClaimsFromUserInfoEndpoint = true;
o.Scope.Add("openid");
o.Scope.Add("profile");
o.Scope.Add("roles");
o.Scope.Add("email");
o.SaveTokens = true;
o.TokenValidationParameters.NameClaimType = "preferred_username";
o.Events.OnTokenValidated = x =>
{
Debug.WriteLine($"OnTokenValidated");
return Task.CompletedTask;
};
}