This is not a question, I just would like to share the solution to resolve this issue to save time for anyone that met the same problem with me when upgrading the package **Microsoft.AspNetCore.Authentication.OpenIdConnect** to version **8.0.6**
I am using .NET 8 Webapi (Cookie, OIDC, JWT). Here’s the error:
> `System.InvalidOperationException: Cannot redirect to the authorization endpoint, the configuration may be missing or invalid.
at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandleChallengeAsyncInternal(AuthenticationProperties properties)
at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandleChallengeAsync(AuthenticationProperties properties)
at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.ChallengeAsync(AuthenticationProperties properties)
at Microsoft.AspNetCore.Authentication.AuthenticationService.ChallengeAsync(HttpContext context, String scheme, AuthenticationProperties properties)
at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.c__DisplayClass0_0.d.MoveNext()
— End of stack trace from previous location —
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
`
Authentication configuration:
.AddOpenIdConnect(options =>
{
options.ClientId = " {clientId}";
options.ClientSecret = "{clientSecret}";
options.Authority = "{authority}";
options.ResponseType = "code";
options.Scope.Add("role");
options.Scope.Add("openid");
options.Scope.Add("email");
});
The reason of this is that we’re missing the package Microsoft.IdentityModel.Protocols.OpenIdConnect since it’s required for new version of Microsoft.AspNetCore.Authentication.OpenIdConnect, but I don’t know why it’s not a dependency while we installing the package.
So just install Microsoft.IdentityModel.Protocols.OpenIdConnect and the issue is solved without adding any new line of code.