C#C
C#10mo ago
balls mcgee

Detailed 401 errors SPA bearer token

I created a minimal example to replicate an issue I'm having with a SPA OIDC and a bearer token

I keep getting 401 from the following setup:

builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme).AddOpenIdConnect(options =>
{
    options.Authority = "http://localhost:3000";
    options.RequireHttpsMetadata = false;
    options.ClientId = "oidcCLIENT";
    options.GetClaimsFromUserInfoEndpoint = true;
});

builder.Services.AddAuthentication(BearerTokenDefaults.AuthenticationScheme).AddBearerToken(options =>
{
    options.ClaimsIssuer = "http://localhost:3000";
});

Very simple setup. I don't know what the issue is. I just need some debugging information.

I changed my appsettings.json

  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    },
    "Microsoft.Hosting.Lifetime": "Information",
    "Microsoft.AspNetCore.Authentication": "debug",
    "Microsoft.AspNetCore.Authorization": "debug"
  },


Nothing prints in the console, though, when I get a 401 from WeatherForecast. Any help would be greatly appreciated.
Was this page helpful?