首页 文章

ASP Core 2.0 app.UseJwtBearerAuthentication失败

提问于
浏览
2

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

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

Startup.csConfigure 方法中,JwtBearerAuthentication的身份验证配置以前就像下面这样:

app.UseJwtBearerAuthentication(new JwtBearerOptions
            {
                AutomaticAuthenticate = true,
                AutomaticChallenge = true,
                TokenValidationParameters = tokenValidationParameters
            });

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

app.UseJwtBearerAuthentication(new JwtBearerOptions
        {
            AutomaticAuthenticate = true,
            AutomaticChallenge = true,
            TokenValidationParameters = tokenValidationParameters,
            AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme
        });

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

1 回答

相关问题