Thanks to Shaik Abid Hussain's Idea i found a solution for .Net 8:
Simply add this line:
options.UseSecurityTokenValidators = true;
Into the .AddJwtBearer(options =>{})
anonym function in the Program.cs File.
This is what it looks like for me now:
var key = Encoding.ASCII.GetBytes(builder.Configuration["Jwt:Secret"]);
builder.Services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.RequireHttpsMetadata = false;
options.SaveToken = true;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(key),
ValidateIssuer = false,
ValidateAudience = false
};
options.UseSecurityTokenValidators = true;
});