Home > Net >  AAD authentication in ASP.NET Core app does not return proper header
AAD authentication in ASP.NET Core app does not return proper header

Time:10-27

I have an AAD authentication in my app. Unfortunatelly when user which is not logged in request any resource I get response header:

 WWW-Authenticate: Bearer

but I should get respone with header:

WWW-Authenticate: Bearer authorization-uri=https://example.com

Is there a way to achieve this?

CodePudding user response:

You can change the JwtBearerOptions.Challenge property:

services.AddAuthentication()
    // If use AddJwtBearer
    .AddJwtBearer(opt =>
    {
        opt.Challenge = "Bearer authorization-uri=https://example.com";
    })
    // If use Microsoft.Identity.Web
    .AddMicrosoftIdentityWebApi(configureJwtBearerOptions: opt =>
    {
        opt.Challenge = "Bearer authorization-uri=https://example.com";
    })
  • Related