Share via

How can I validate accessToken on the protected API in NodeJS + Express?

Stefano Cappa 0 Reputation points
2026-02-13T16:06:24.3366667+00:00

I ctreated a small app using this example https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/samples/msal-node-samples/auth-code-pkce/src/index.ts as a starting point to login and obtain an accessToken from Entra. Everything seems ok, because I receive a valid JWT as expected. Then I created another microservice to expose protected APIs, so I need to implement a JWT validation.

When I try to validate accessToken via jwks-rsa and jsonwebtoken packages I always receive error: "invalid signature".

I don't understand how to fix this issue and how to debug it to understand what is wrong.

Do you have any suggestions?

thanks

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.