Client Credentials M2M Login customize token

Hi all,

I created a test application, called testM2M.
I also set some metadata in the advanced settings section of this application.
I tried this rule but it doens’t change anything in my jwt token:

function (user, context, callback) {
  var namespace = "";
  user.user_metadata = user.user_metadata || {};
  context.idToken[namespace + "user_metadata"] = user.user_metadata; 
  callback(null, user, context);

How can I add this information in my jwt token I get after calling the /oauth/token API? Is this possibile? If this is not possibile, can I use the clientID contained in the token to retrieve metadata?
Can you help me here?

Hi Piero,

If you are using client credentials, there is no user, and so there is no user_metadata.

Are you looking for the client metadata? Try this:


1 Like

Yeah, I meant client metadata, sorry.

Can I add them in my jwt token?

Yes, see the doc I linked to. You can refer to client_metadata as context.clientMetadata


1 Like