SecurityTokenMalformedException after updating to .NET 8

This a closed issue here: #52286

I only had these 2 packages in my project:

  • Microsoft.IdentityModel.Tokens
  • Microsoft.AspNetCore.Authentication.JwtBearer

What worked for me was to add the Microsoft.IdentityModel.JsonWebTokens package.