Account linking with Actions - `getManagementApiToken`

I’ve seen this simple example of account linking through actions

but I’m stuck with the getManagementApiToken function, that maybe I need to write on my own.
Can someone provide any guidance for this function? how to use the event and api variables?

Moreover, what should be the value of event.secrets.TENANT_DOMAIN?


Hi @tal1,

Welcome to the Auth0 Community!

It looks like the getManagementApiToken method is suppose to be a hardcoded value of your Management API token.

However, this is not ideal because the API token can expire and cause the code to fail in the future.

In this case, consider replacing the following code snippet:

  const token = await getManagementApiToken(event, api);
  const domain = event.secrets.TENANT_DOMAIN;
  const management = new ManagementClient({ domain, token });

with the following initialization of the ManagementClient class:

  const management = new ManagementClient({
      domain: event.secrets.domain,
      clientId: event.secrets.clientId,
      clientSecret: event.secrets.clientSecret,

For managing secrets, you can configure them in the Action code editor. I recommend following the steps outlined in the Write Your First Action - Add a secret documentation.

If you have any questions, feel free to ask.


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