-
Notifications
You must be signed in to change notification settings - Fork 23
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
What is the appropriate error response for an invalid authentication token? #107
Comments
I’ve opted for (Originally published at: https://v2.jacky.wtf/post/c6a3f445-5c1c-4a8f-90f2-43e573eab378) |
My server, which uses Spring Security as a base to handle OAuth2-related goodness responds with the following:
It responds like so if an empty token is provided:
And if no authentication is provided at all:
https://tools.ietf.org/html/rfc6750#section-3.1 defines:
So Jacky's point could be argued as a suitable alternative, as the request is bad, as no authentication has been provided |
401 Unauthorized - This means the user isn't not authorized to access a resource. It usually returns when the user isn't authenticated. |
The standard currently defines three error responses related to authentication/authorization:
What if the client did send an Authorization header with an access token but that token is invalid? This case doesn’t seem to be covered by the first response, which refers to “the authenticated user.” The second response assumes there is no token at all. The third response indicates that there is a problem with the scope specifically—this doesn’t seem like it would be an appropriate response if the token were malformed or otherwise invalid.
Does the spec already cover this case and I’m just not seeing it? Or is this not yet addressed? In the latter case, as a strawman proposal, I suggest that the “401 unauthorized” case be expanded as follows:
The text was updated successfully, but these errors were encountered: