auth0 / express-jwt

connect/express middleware that validates a JsonWebToken (JWT) and set the req.user with the attributes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Please document error codes

lonix1 opened this issue · comments

Would be very helpful for the docs to clearly document the various types of error codes.

I had all sorts of problems because I didn't know which errors were coming from this library, and what they meant.

I went through the code and found these:

  • 'credentials_bad_scheme'
  • 'credentials_bad_format'
  • 'credentials_required'
  • 'invalid_token' x2
  • 'revoked_token'

Note that the 'invalid_token' error code is used in two cases: 1) because of a failed decode and 2) because of a failed verify. There should be a distinction between them, but that is a separate issue (perhaps we should use different codes, or different messages).

+1 to this. In order to provide proper logging and feedback related these errors, it would be great to know what to expect.

I also went through the source, and it looks like those are the full collection of errors for this library.
Since it uses node-jsonwebtoken under the hood, here are some additional codes:
https://github.com/auth0/node-jsonwebtoken#errors--codes

Test comment.