私はdot net core 1.1を使用してWebアプリケーションを開発しました。私がコア2.0をaspにアップデートするまで、うまくいきました。アプリケーションを使用しようとすると、その後、それがこのエラーを報告します。ASPコア2.0 app.UseJwtBearerAuthenticationが失敗しました
InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
Startup.cs
のConfigure
方法でJwtBearerAuthenticationの認証設定は、以前に怒鳴るようなものだった:私は、このエラーに直面した後
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
TokenValidationParameters = tokenValidationParameters
});
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
TokenValidationParameters = tokenValidationParameters,
AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme
});
しかし、まだエラーメッセージが生きています。エラーの箇所が間違っているのでしょうか、認証システムを動作させるために追加の設定を追加する必要がありますか?
認証が2.0で変更されました。さらに詳しい情報はhttps://github.com/aspnet/Announcements/issues/262 – juunas
TL; DR:必要なミドルウェアは 'app.UseAuthentication();'で、 'ConfigureServices()'でサービスとして認証ハンドラを定義します。 – juunas