0

I am using .Net Core 2. I need to add a simple token endpoint. I was following this article but found that the below method is obsolete in .Net Core 2

app.UseJwtBearerAuthentication();

Quoting the second link:

Configure(): UseXyzAuthentication() has been replaced by ConfigureService(): AddXyz()

Therefore, in ConfigureService method, i am trying to use something like

services.AddAuthentication(new JwtBearerOptions());

which is not correct, i know but how to achieve this? Unfortunately, i couldn't find any help on web.

Thanks

Mohsin
  • 692
  • 1
  • 7
  • 15

3 Answers3

1

These are implemented some what in a more efficient manner in core 2.0 possible duplicate

Salman Taj
  • 46
  • 3
0

It may also explain a lot easier and technical manner. Good solution

Salman Taj
  • 46
  • 3
0

The migration guide contains a whole article dedicated to the changes in Authentication and Identity:

In Configure you have to call app.UseAuthentication();.

The code in ConfigureServices should be:

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
    .AddJwtBearer(options => {
        options.Audience = "http://localhost:5001/";
        options.Authority = "http://localhost:5000/";
    });
Stephan
  • 2,028
  • 16
  • 19