When using minimal hosting model (WebApplication.CreateBuilder(args)) you don't need to write app.UseAuthentication() explicitly. It's implicitly called as the first middleware (see this). So, just remove the line.