Implementing personal access token

Thanks @tyf for the prompt reply. I tried the following things and none of them seem to work:

  • Rules - i had a rule which will add user metadata into the JWT token for the PKCE flow and it works fine, i just extended it to take care of M2M
function (user, context, callback) {
  const namespace = "https://unskript.io/"; // my_namespace is a placeholder...
  const user_metadata = user.app_metadata || {};
  if (user_metadata !== {}) {
    context.accessToken[namespace + "app_metadata"] = user_metadata;
  } else {
		context.accessToken[namespace + "app_metadata"] = context.clientMetadata;
  }
  return callback(null, user, context);
}
  • Actions -
exports.onExecuteCredentialsExchange = async (event, api) => {
  api.accessToken.setCustomClaim("https://foo.bar", event.client.metadata)
};

When i do the curl POST to get the access token

POST https://<YOUR_AUTH0_DOMAIN>/oauth/token
Content-Type: application/json
{
  "audience": "<API_IDENTIFIER>",
  "grant_type": "client_credentials",
  "client_id": "<YOUR_CLIENT_ID>",
  "client_secret": "<YOUR_CLIENT_SECRET>"
}

and i parse the JWT token, i dont see the custom claim or app_metadata. What am i doing wrong here?