ASP Core 2.0 app.UseJwtBearerAuthentication失败

Con*_*ver 4 restful-authentication asp.net-core

我使用dot net core 1.1开发了一个Web应用程序.它已经工作正常,直到我更新到asp核心2.0.然后,当尝试使用该应用程序时,它会报告此错误:

InvalidOperationException:未指定authenticationScheme,并且未找到DefaultChallengeScheme.

JwtBearerAuthentication的身份验证配置,以前的Configure方法Startup.cs如下:

app.UseJwtBearerAuthentication(new JwtBearerOptions
            {
                AutomaticAuthenticate = true,
                AutomaticChallenge = true,
                TokenValidationParameters = tokenValidationParameters
            });
Run Code Online (Sandbox Code Playgroud)

面对这个错误后,我已经更新了这个:

app.UseJwtBearerAuthentication(new JwtBearerOptions
        {
            AutomaticAuthenticate = true,
            AutomaticChallenge = true,
            TokenValidationParameters = tokenValidationParameters,
            AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme
        });
Run Code Online (Sandbox Code Playgroud)

但仍然是错误消息仍然存在.我错误地找错了地方,或者我必须为身份验证系统添加其他配置吗?

Con*_*ver 6

我刚刚关注这篇文章,一切都很完美.

将身份验证和身份迁移到ASP.NET Core 2.0

希望它有助于其他.

TG.