401 unauthorized
HTTP 401 Unauthorized is a response status indicating that a request lacks valid authentication credentials for the requested resource.
Secure APIs
The HTTP 401 status code indicates that a request lacks valid authentication credentials.
- How it is used
- Distinguishes missing or invalid authentication from authenticated users who lack permission to perform an operation.
- How deep it goes
- Defines the status distinction and applies it in an automated endpoint test, without detailing authentication internals.
- Examples
- Tests an unauthenticated lesson request and runs it with pytest against a FastAPI service.
- What you can do after
- Diagnose/debug with it, identifying authentication failures and separating them from authorization failures in automated API tests.
ASP.NET Core in Action, 3e
A 401 Unauthorized response is an HTTP response indicating that authentication is required or has failed for the request.
- How it is used
- Uses 401 responses to signal failed API authentication and stop unauthenticated requests before endpoint execution.
- How deep it goes
- Explains challenges, API behavior, and bearer-header mistakes, but defers detailed authorization requirements and failure logging.
- Examples
- Uses a protected Edit action and an Authorization: Bearer <token> request to demonstrate successful correction of a 401.
- What you can do after
- Diagnose 401 responses by checking the bearer scheme, spacing, spelling, and token value before retrying an API request.
Read how ASP.NET Core in Action, 3e explains 401 unauthorized →
Related concepts
- 403 Forbiddencontrasts with · 403 Forbidden is an HTTP response status indicating that the server understood a request but refuses to authorize the requested access or operation.
- authentication errorproduced by · An authentication error is a failure to verify the identity represented by credentials submitted for access to a service or resource.
- api callproduced by · An API call is a programmatic request or invocation through an application programming interface to access data or invoke an operation.
- HTTP response codekind of · An HTTP status code is a standardized three-digit value in an HTTP response that indicates the outcome of processing the corresponding request.
- authenticationproduced by · Authentication is the process of establishing or verifying the identity of a user, service, device, or other communicating entity.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

