net core 2.2 to 3.0 authentication migration AddOpenIdConnect

Viewed 7903

Currently I'm in upgrading asp net core 2.2 web site to net core 3.0 that uses Identity Server 4 authentication and found issue that stops me to finish this task: In .net core 3.0 there is no AddOpenIdConnect method in OpenIdConnectExtensions (docs are clear about it:

Link

So is there any substitute in .net core 3.0?

Startup.cs that works in net core 2.2

IServiceProvider ConfigureServices(IServiceCollection services)
{    
    services.AddAuthentication(options =>
                    {
                        options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    })
                    .AddCookie(options =>
                    {
                        options.SlidingExpiration = true;
                        options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
                    })
                    .AddOpenIdConnect("oidc", options =>
                    {
                        options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;

                        options.Authority = "sso url";
                        options.RequireHttpsMetadata = false;

                        options.ClientId = "client_id";
                        options.ClientSecret = "secret";
                        options.ResponseType = $"{OpenIdConnectParameterNames.Code} {OpenIdConnectParameterNames.IdToken}";

                        options.SaveTokens = true;
                        options.GetClaimsFromUserInfoEndpoint = true;                    
                    })
2 Answers

For recognizing AddOpenIdConnect, from version 3.0 onwards, you must install package:

Microsoft.AspNetCore.Authentication.OpenIdConnect
Related