title: What's the appropriate HTTP status code to return if a user tries logging in with an incorrect username / password, but correct format?
body: <p>A similar question is posted here: <a href="https://stackoverflow.com/questions/1959947/whats-an-appropriate-http-status-code-to-return-by-a-rest-api-service-for-a-val">What&#39;s an appropriate HTTP status code to return by a REST API service for a validation failure?</a></p>
  
  <p>The answer in the thread above states that "For instance if the URI is supposed to have an ISO-8601 date and you find that it's in the wrong format or refers to February 31st, then you would return an HTTP 400. Ditto if you expect well-formed XML in an entity body and it fails to parse."</p>
  
  <p>However, what happens if the user submitted correctly formatted data? By this I mean, the user submitted a plain alphabetical string / text for the username and password (which is perfectly valid for my application). The only issue is that the password did not match with the username. In this case, 400 will be incorrect because it is perfectly valid syntax and well-formed. </p>
  
  <p>A 401 would be incorrect (as suggested here: <a href="https://stackoverflow.com/questions/26093875/wich-http-status-code-to-say-username-or-password-were-incorrect">Which HTTP status code to say username or password were incorrect?</a>) because the user is not trying to access any page, he is simply trying to login and entered data which does not match.</p>
  
  <p>If you look back at the first post I linked to, the second answer states that 422 is the correct response (and it looks correct to me), however, I am using Django Rest Framework and 422 is not part of the status codes (a list of the status codes which are part of DRF can be found here: <a href="http://www.django-rest-framework.org/api-guide/status-codes/#client-error-4xx" rel="noreferrer">http://www.django-rest-framework.org/api-guide/status-codes/#client-error-4xx</a>)</p>
  
  <p>404 also doesn't look right because the data is successfully accepted and not refused.</p>
  
  <p>With that said, what is the real correct response which should be used?</p>