Now that we know why we're using JWTs, we need to make a few configuration changes to enable authentication and specify the mechanism we wish to use. We'll start by opening the Startup.cs file, and finding the following piece of code within it:
services.AddIdentity<AppUser, AppRole>() .AddEntityFrameworkStores<EcommerceContext>() .AddDefaultTokenProviders();
Directly beneath this section, add the following:
services.AddAuthentication(options =>{ options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;})
If we were using cookie-based authentication, we wouldn't need this code at all, but since we're using JWTs, we ...