How to extract userId from JWT AccessToken in Node.JS API

Hi, I’d like to be able to send a request with an accessToken to a NodeJS API.

After validation, I would like to extract the userId attribute from the token so that it can be used in database queries.

Is there a code example someone could share to demonstrate how this would be done?

Hi @john6

The sub claim should have the user ID.

John

That’s great news! I have been able to extract the sub value of the token using the React API.

However I’m not clear on how this would be done via the Express SDK.

I’ve searched the documentation [https://auth0.com/docs/quickstart/backend/nodejs/02-using] but I haven’t found a code example.

Could you provide a few lines to demonstrate how this can be done?

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