状态码 401 Unauthorized 代表客户端错误,指的是由于缺乏目标资源要求的身份验证凭证,发送的请求未得到满足。

这个状态码会与   WWW-Authenticate 首部一起发送,其中包含有如何进行验证的信息。

这个状态类似于 403, 但是在该情况下,依然可以进行身份验证。

状态

401 Unauthorized

响应示例

HTTP/1.1 401 Unauthorized 
Date: Wed, 21 Oct 2015 07:28:00 GMT
WWW-Authenticate: Basic realm="Access to staging site"

规范

Specification Title
RFC 7235, section 3.1: 401 Unauthorized HTTP/1.1: Authentication

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support

相关内容

文档标签和贡献者

此页面的贡献者: WayneCui
最后编辑者: WayneCui,