WWW-Authenticate Header Explained
What the HTTP WWW-Authenticate header does and when it's used.
Published October 16, 2026
WWW-Authenticate is sent with a 401 response and tells the client which authentication scheme to use, such as Basic or Bearer.
How it works
It makes browsers show a login prompt for Basic auth.
The WWW-Authenticate header is part of the HTTP message and is case-insensitive in name.
In a real exchange
curl -i https://example.com/
WWW-Authenticate: Bearer realm="api"
Practical examples
The header
WWW-Authenticate: Bearer realm="api"Set or use it in code
res.status(401).set('WWW-Authenticate','Bearer realm="api"')Inspect it
curl -sI https://example.com | grep -i 'www-authenticate'Common mistakes
- Missing it on 401
- Using Basic without HTTPS
- Revealing too much in error_description
Key takeaways
- WWW-Authenticate: WWW-Authenticate is sent with a 401 response and tells the client which authentication scheme to use, such as Basic or Bearer.
- Check it in browser DevTools → Network.
- Test with curl -I before deploying.
FAQ
401 without the header?
It is technically required but often omitted by APIs.
Is WWW-Authenticate case sensitive?
Header names are case-insensitive; values may not be.