AddJwtBearer OnAuthenticationFailed return custom error

It’s important to note that both the aspnet-contrib OAuth2 validation and the MSFT JWT handler automatically return a WWW-Authenticate response header containing an error code/description when a 401 response is returned: If you think the standard behavior is not convenient enough, you can use the events model to manually handle the challenge. E.g: services.AddAuthentication() .AddJwtBearer(options … Read more

tech