Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification required on usage of UNAUTHENTICATED and AUTHENTICATION_REQUIRED error codes #368

Open
eric-murray opened this issue Jan 3, 2025 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@eric-murray
Copy link
Collaborator

Problem description
The API guidelines currently define two 401 error response codes, UNAUTHENTICATED and AUTHENTICATION_REQUIRED. It is not clear if these are synonyms, or if they correspond to different error scenarios.

Expected action
The usage of these two error codes should be clarified.

  • Either remove one, combining them into a single 401 error response code; or
  • Clarify the different error scenarios to which they correspond

My proposal would be:

AUTHENTICATION_REQUIRED: The access token lifetime has expired. This should be the most common error scenario.
UNAUTHENTICATED: The access token is either missing, is not and never was a valid access token (e.g. a random string, or an access token issued by a different API provider), or has been revoked or otherwise invalidated (e.g. if reported as having been leaked or stolen).

However, I'm also happy just to have a single 401 error code

Additional context

@eric-murray eric-murray added the documentation Improvements or additions to documentation label Jan 3, 2025
@sachinvodafone
Copy link
Collaborator

I agree with your last suggestion, @eric-murray. It makes more sense to use a single error code, like 401 UNAUTHORIZED, rather than having both UNAUTHENTICATED and AUTHENTICATION_REQUIRED, since they essentially convey the same meaning. Personally, seeing either of these codes doesn't provide much clarity, as they don't offer much insight on their own without further details.

@Kevsy
Copy link
Collaborator

Kevsy commented Jan 3, 2025

401 Unauthorized covers both a lack of authentication credentials and invalid credentials, and an error message can convey what action is required to retry - so I think just 401 can cover it (although it's not ideal that the status code name is Unauthorized - which is rather the scope of 403 Forbidden - instead of Unauthenticated).

@PedroDiez
Copy link
Collaborator

Hi, both approaches work with us.

In order to simplify, our proposal is to keep 401 - UNAUTHENTICATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants