jwtVerify from node express needs an audience
I am trying to set up an express server that can verify my token. This is my current code:
However I am getting an error as soon as i try to run the node server:
Is this a known issue
3 Replies
Hi Pranay,
The error you're encountering—"Cannot destructure property 'audience' of 't' as it is undefined"—is typically triggered when the verifier expects an audience claim in the token but doesn't find one. This means that either the token generated by your client doesn’t include the expected
aud
claim, or the verifier isn’t being provided with the correct options to validate it.
In fact, similar issues have been discussed in community forums. For instance, users on Answer Overflow have noted that when the token’s aud
claim is missing or empty (even though it appears correctly when generated via the Kinde portal), the jwtVerify
middleware fails because it tries to destructure an undefined audience
field. They suggest double-checking your API configuration in the Kinde dashboard to ensure the audience is correctly set and that your client requests the token with the proper audience parameter. Additionally, verify that you’re using the latest version of the SDK, as updates may include fixes or better error messages for these scenarios.
For more context, you can refer to discussions like this one: https://www.answeroverflow.com/m/1342410814795157575
I hope this helps clarify the issue. If you need further assistance or additional troubleshooting steps, please let me knowGot it. So I am generating the access token from React Native directly using:
But now when I try to login, my client shows an error message like this:
I can't figure out where on Kinde do I enable the audience paramter?
Hi Pranay,
Thanks for the detailed reproduction steps. Based on the error message, it does appear that the audience you’re providing might not be whitelisted for your OAuth 2.0 client. I’m going to discuss this with my team to confirm if whitelisting the audience is required and get back to you with a definitive solution.
Hi Pranay,
It seem the error occurs because the audience parameter in your login request isn’t whitelisted in your Kinde Dashboard settings.
If you're accessing Kinde’s APIs via machine-to-machine (M2M) authentication, you should use
{your_domain}.kinde.com/api
as the audience.
However, if you're using a custom domain for authentication, you'll need to add your custom domain as an API under Settings > API and then whitelist it in your application settings.
Please try this update and let us know if you need further assistance