'.Net core 6 authorization with bearer token
I cannot get authorization work with openidconnect. I want to send a token as a header.
My code in program.cs:
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
}).AddCookie()
.AddOpenIdConnect(o =>
{
o.ClientId = "id";
o.ClientSecret = "secret";
o.Authority = "https://something.onelogin.com/oidc/2";
o.ResponseType = "code";
o.GetClaimsFromUserInfoEndpoint = true;
}
);
In addition to this I have app.AddAuthentication() etc.
However, when sending a token as a header: "Authorization":"Bearer ey...", I cannot access the endpoints.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
