I’ve spent the last few days diving into the module code for express-oauth2-jwt-bearer in order to understand the cause of an error when I am using mock-jwks, with no luck. I am hoping somebody in the community might be able to help.
Context: I have stubbed an API, which when called with an auth0 token performs as expected.
Because I want to run unit tests, I selected mock-jwks so I can create tokens on the fly and test my API.
Again, when calling the API using mock-jwks and an auth0 token, all goes well.
When I call the API with a token created by mock-jwks, I get an error of no applicable key found.
This appears to be because there is no match between the ‘kid’ values.
I strongly suspect it’s got something to do with how I setup express-oauth2-jwt-bearer in the first place. As the combination of express-oauth2-jwt-bearer, mock-jwks and an auth0 token works fine. Perhaps I’m supposed to tell express-oauth2-jwt-bearer something about the mock-jwks key, but if so, how?
If it helps, having stepped through the code, I see where the kid values are checked at line 50 below:
i really need help as I’m three days into this issue and it seems like a rookie error is in play!