101 · Question #506
Which HTTP response code is returned when a web server requires authentication to access a resource?
The correct answer is B. 401. HTTP 401 Unauthorized is returned by a web server when the requested resource requires valid authentication credentials that were not provided.
Question
Which HTTP response code is returned when a web server requires authentication to access a resource?
Options
- A500
- B401
- C302
- D100
How the community answered
(20 responses)- A5% (1)
- B90% (18)
- D5% (1)
Why each option
HTTP 401 Unauthorized is returned by a web server when the requested resource requires valid authentication credentials that were not provided.
HTTP 500 Internal Server Error indicates an unexpected server-side failure during request processing, not an authentication requirement.
The HTTP 401 status code, defined in RFC 9110, explicitly signals that the request has not been applied because it lacks valid authentication credentials for the target resource. The server typically includes a WWW-Authenticate header in the 401 response to inform the client which authentication scheme is required. This is distinct from 403 Forbidden, where credentials may be present but access is still denied.
HTTP 302 Found is a redirect response that tells the client the resource has temporarily moved to a different URL, and is unrelated to authentication requirements.
HTTP 100 Continue is an informational status indicating the server has received the request headers and the client should proceed to send the request body, not an authentication challenge.
Concept tested: HTTP response status codes - authentication and authorization
Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
Topics
Community Discussion
No community discussion yet for this question.