I am developing an application that will be using Okta, and has been following the tutorials as shown on the site. However as my project is on .NET Core 8, it seems that there are some groundbreaking changes to it that has led to this error:
Microsoft.IdentityModel.Tokens.SecurityTokenException: The Validated Security Token must be of type JsonWebToken, but instead its type is ‘System.IdentityModel.Tokens.Jwt.JwtSecurityToken’.
at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.ValidateTokenUsingHandlerAsync(String idToken, AuthenticationProperties properties, TokenValidationParameters validationParameters)
at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandleRemoteAuthenticateAsync()
This is my Program.cs file:
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOktaMvc(new OktaMvcOptions
{
OktaDomain = builder.Configuration.GetValue(“Okta:OktaDomain”),
ClientId = builder.Configuration.GetValue(“Okta:ClientId”),
ClientSecret = builder.Configuration.GetValue(“Okta:ClientSecret”),
AuthorizationServerId = builder.Configuration.GetValue(“Okta:AuthorizationServerId”),
});
var app = builder.Build();
Does anyone know how to fix the error?