status code for unauthorized code example
Example 1: 401 vs 403
401 Unauthorized VS 403 Forbidden
401 Unauthorized meaning
you did not provide a credential or correct credentials to send the
request
you are encorouranged to try again with correct credentials
403 Forbidden
even you did provide valid credentials
you are not authorized to take this action by who you are
because you do not have authority or permission
Do not bother to try again !
Example 2: unauthorized status code
HTTP 401 : Unauthorized client error status response code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource