Best of all, I can offer an HTTP 401 status code with a WWW-Authenticate header.
The problem with 403 requests is RFC 2616 : "Authorization will not help, and the request SHOULD NOT be repeated." (i.e. it doesn’t matter if you are authenticated or not, you won’t ever get access to this resource ever).
The problem with 401 requests is that they "MUST include a WWW-Authenticate header field." As someone pointed out , he does not violate the specification in order to use a custom value in the WWW-Authenticate header.
I see no reason in RFC 2617 why the status of HTTP 401 in combination with a custom WWW-Authenticate header like this will not be all right:
WWW-Authenticate: MyAuthScheme realm="http://example.com"
The oAuth spec actually seems to do just that, as they recommend it (although they mean an odd interpretation of the RFC)
WWW-Authenticate: OAuth realm="http://server.example.com/"
This, apparently, does not make much sense in the RFC, but I can’t see that it is prohibited by it (it does not seem to conflict with any MUST or SHOULD, SHOULD or SHOULD be able to).
I would like to have a more specific HTTP status code for timeouts, and for things like CSRF tokens were invalid, so that was clearer.
Iain Collins Apr 13 '12 at 4:40 2012-04-13 04:40
source share