Auth0 Home Blog Docs

How to get the user_id field in Auth0 Hooks?


I’m trying Hooks features in Auth0, specifically Client Credentials Exchange hook. I am trying to get the user_id field, or user metadata in jwt.


@fahadmiq1 thanks for submitting the feature request!

A quick note, the client_credentials exchange is a machine to machine exchange. In other words this is an OAuth 2.0 flow where an application is trying to get a token issued to itself. Since this flow is designed for machine to machine authentication it doesn’t make sense for user_id to be present.


actually i need user detail in jwt, how can i achieve it. I have created a machine-to-machine application for this purpose also created some users in username-Password-Authentication database


It is unclear the details of the use case, however there are flows to issue a token on behalf of a user. Theses include Authorization Code Flow, Implicit Flow, Resource Owner, and Cross-Origin Authentication. All of these flows require a user to be challenged for some type of credential.

You should not use client credentials for anything expecting user details in the jwt. With this flow there is no way to guarantee the user was properly auhorized.