Netcore upgrade from 1.1 to 2.0, out of the wrong, because when using the JWT token
Refer to the https://github.com/aspnet/Security/issues/1310#issuecomment-314842779 address,
chris31389 answers the questions Pinpointtownes ask, as follows:
PublicClassstartup{public void configureservices ( Iservicecollection services) {services. Addauthentication (options = options. Defaultscheme = Jwtbearerdefaults.authenticationscheme; }) . Addjwtbearer (options = options. authority = "Http://localhost:30940/"; Options. Audience = "Resource-server"; Options. Requirehttpsmetadata = false;}); } public void configure ( Iapplicationbuilder app) {app. Useauthentication (); //...}
So my solution is as follows: Configure the function that was originally written in Configure to Configureservices.
/span>
Services. Addauthentication (options ={options. Defaultscheme=Jwtbearerdefaults.authenticationscheme; }) . Addjwtbearer (Options={options. Tokenvalidationparameters=Newtokenvalidationparameters {Issuersigningkey=Tokenauthoption.key, Validaudience=tokenauthoption.audience, Validissuer=Tokenauthoption.issuer, Validateissuersigningkey=true, Validatelifetime=true, Clockskew= Timespan.fromminutes (0), }; });
Jwtbearerappbuilderextensions.usejwtbearerauthentication (Iapplicationbuilder