I’m trying to obtain the decoded JWT payload using the express-jwt from auth0 as a middleware in my expressjs application. For the token to be used for authentication, I have to use a custom async function to process the token first before providing it to express-jwt. I understand that I can write a custom function under the getToken parameter as documented in express-jwt as shown below, but it does not work with async function.
To overcome this limitation, I included the jwt() as part of a larger middleware function that first process the token, and then providing it to jwt(). The unprocessed token is attached to my headers. My code structure is as follows:
While I’m able to authenticate my routes without any issue, I need to get the decoded JWT payload for further uses. By default, as written in the documentation, the decoded payload should have been attached to req.user, but when I try to console.log it, it shows undefined. I have also tried adding requestProperty but it does not work as well. The documentation for resultProperty is not very clear, so I could not get that to work too.
I very much appreciate if someone can point me towards right direction to help me achieve the expected outcome for my middleware. Thank you!
Thanks for reporting that! Can I ask you to copy paste it and create a GitHub issue in the repo so we can work on that directly with the repo maintainers? Thank you! Make sure to share the link to the issue here with us in the thread
Hello, I have opened up an issue on GitHub, but it seems like the repo is not active anymore as I saw that issues have been left unanswered since Aug 19. Hopefully someone can help me with this. Thanks!