Authorization failed. These requirements were not met: DenyAnonymousAuthorizationRequirement: Requires an authenticated user.
in the server log means a request reached an endpoint that needs a signed-in user, and
the request carried no identity the app accepted. The caller sees a 401. Send
a valid bearer token, the only scheme this app has, or find out why the one you send
is not accepted.
In this test the request had no Authorization header at all. The same request
with a token from the test's own token endpoint returned 200 and logged nothing.
The error
What the client got, and the line the server console printed for that request. The line
is written at Information level by
Microsoft.AspNetCore.Authorization.DefaultAuthorizationService:
PS> curl.exe -s -i http://127.0.0.1:15630/patients
HTTP/1.1 401 Unauthorized
Content-Length: 0
Date: Sat, 14 Nov 2026 01:26:30 GMT
Server: Kestrel
WWW-Authenticate: Bearer
...
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
Authorization failed. These requirements were not met:
DenyAnonymousAuthorizationRequirement: Requires an authenticated user.
The template's appsettings.json sets Microsoft.AspNetCore to
Warning, and with that setting the same 401 left no line at all in the
console. The line appeared after one entry was added:
...
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Microsoft.AspNetCore.Authorization": "Information"
}
},
...
Why it happens
The endpoint was mapped with .RequireAuthorization() and no policy name, which
asks only for an authenticated user. That requirement is the
DenyAnonymousAuthorizationRequirement the log names. A request without a
token is anonymous, so the requirement failed and JWT bearer, the default scheme,
answered with 401 and WWW-Authenticate: Bearer.
The log line says which requirement failed, not why the user is anonymous. This test
covered only a request with no Authorization header at all; a request with a
rejected token was not part of it.
The fix
Send a token the app accepts. The test token came from the app's own
/token endpoint, signed with a made-up test key:
PS> $token = curl.exe -s http://127.0.0.1:15630/token
PS> curl.exe -s -i -H "Authorization: Bearer $token" http://127.0.0.1:15630/patients
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sat, 14 Nov 2026 01:26:30 GMT
Server: Kestrel
Transfer-Encoding: chunked
["Maria Garcia","David Chen"]
No authorization line was logged for this request, and the response carried the two patient names the endpoint returns.
How it was reproduced
A minimal API made with dotnet new web -f net10.0 on SDK 11.0.100, with
Microsoft.AspNetCore.Authentication.JwtBearer 10.0.0 (issuer, audience and a
test-only symmetric key), running on Microsoft.AspNetCore.App 10.0.15 in the
Development environment, built and started by a small script, start.ps1, which runs dotnet build -nologo -v q in the project folder and then bin\Debug\net10.0\FixLab.exe --urls http://127.0.0.1:15630. The token endpoint used
JsonWebTokenHandler; the token went into a PowerShell variable and was sent
with curl.exe. The run without the logging entry was repeated to show that
the template levels print nothing. FixLab, port 15630, the routes /patients and
/token, the subject david.chen and the patient names are the
test's own.
Frequently asked
- What does DenyAnonymousAuthorizationRequirement: Requires an authenticated user mean?
- The endpoint requires a signed-in user and the request had no identity the app accepted. In the test a request without an Authorization header logged this line and got 401.
- Why don't I see 'Authorization failed' in my ASP.NET Core logs?
- The line is written at Information level and the template sets Microsoft.AspNetCore to Warning. Adding "Microsoft.AspNetCore.Authorization": "Information" under Logging:LogLevel made it appear in the test.
- How do I fix the 401 behind 'Requires an authenticated user'?
- Send a bearer token the app accepts. In the test the same request with a valid bearer token returned 200 and no authorization line was logged.
More decoded errors in the Fixes category. When the user is signed in but lacks a role, the log names a different requirement: 'RolesAuthorizationRequirement:User.IsInRole must be true'.