User object "data" was not found - Express Typescript JWT

I am getting the following error in Express when attempting to validate the permissions of an incoming request with JWT:

UnauthorizedError: user object “user” was not found. Check your configuration

I am using express-jwt to verifiy the incoming JWT. This seems to be working. However for checking the token’s permissions, I am using express-jwt-permissions, which according to the documentation is supposed to work with express-jwt, exactly as I am doing, but I keep getting that error.

I decoded my token using jwt.io and I indeed have no “user” object inside the payload. However I was left with the impression that this is not a problem, because express-jwt should set decode and create the object inside the request ( I am not sure about this part though).

Is this a problem of the library(ies) handling the token verification, with my configuration or something with the token itself (even though it is valid)?

Configuration:

Hi Ivan! I met the same issue in my project. May I ask if you solved this problem finally?

Its been a while since I did, from what I recall, I needed to specify which property in the request contains the user information. requestProperty: 'user', adding this just before the audience property fixed it for me. Of course, user should be replaced with the name of the user prop in the request.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.