401 Unauthorized Vs 403 Forbidden: Which Is The Right Status Code For When The User Has Not Logged In?
Answer : The exact satisfying one-time-for-all answer I found is: Short answer: 401 Unauthorized Description: While we know first is authentication (has the user logged-in or not?) and then we will go into authorization (does he have the needed privilege or not?), but here's the key that makes us mistake: But isn’t “401 Unauthorized” about authorization, not authentication? Back when the HTTP spec (RFC 2616) was written, the two words may not have been as widely understood to be distinct. It’s clear from the description and other supporting texts that 401 is about authentication. From HTTP Status Codes 401 Unauthorized and 403 Forbidden for Authentication and Authorization (and OAuth). So maybe, if we want to rewrite the standards! focusing enough on each words, we may refer to the following table: Status Code | Old foggy naming | New clear naming | Use case +++++++++++ | ++++++++++++++++ | ++++++++++++++++ | ++++++++++++++++++++++++++++++++++ 401 | Unaut...