Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP Core 2.0 app.UseJwtBearerAuthentication fails

I have developed a web application using dot net core 1.1. It was working fine till I've updated to asp core 2.0. Then when trying to use the application, it reports this error:

InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.

The authentication config of JwtBearerAuthentication, in the Configure method of Startup.cs was previously like bellow:

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

After facing this error I have updated that to this one:

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

But still the error message is alive. Am I looking wrong place for the error or I have have to add additional configurations for the authentication system to work?

like image 537
ConductedClever Avatar asked Jul 19 '17 10:07

ConductedClever


1 Answers

I've just followed this article and everything goes perfect.

Migrating Authentication and Identity to ASP.NET Core 2.0

Hope it helps other.

TG.

like image 57
ConductedClever Avatar answered Sep 18 '22 04:09

ConductedClever