Correct HTTP status code for login form?

后端 未结 4 2029
刺人心
刺人心 2020-12-28 15:29

I am implementing the authentication for an app, and I am using a pluggable system with \"authentication methods\". This allows me to implement both HTTP Basic as well as HT

4条回答
  •  清酒与你
    2020-12-28 15:36

    For HTML I think you should respond with a 400.

    This may be true for non-HTML requests as well, since 401 is as far as I understand it more designed to respond to a request to content that requires authentication, not to respond to an authentication request.

    HTML does not always allow for pure use of RESTful APIs, so it's ok to cut corners here and there imo, but maybe there is a better way I'm not seeing in this particular case.

提交回复
热议问题