Skip to content

Allow to decentralise Management API token cache #792

@KillianHmyd

Description

@KillianHmyd

Describe the problem you'd like to have solved

As the cache of the Management API's token is local to the execution process we end-up generating a lot of Machine-to-Machine tokens when scaling our application horizontally. Having a way to decentralised the cache would help us to reduce the number of generated tokens.

Describe the ideal solution

Ideally we could pass a method to the token properties to handle ourselves the caching mechanism:

const auth0ManagementClient = new ManagementClient({
  token: () => Promise.resolve('my-token')
  clientId,
  domain,
  audience,
  scope,
});

We can also imagine leveraging on the existing Automatic Management API Token Retrieval features:

const auth0ManagementClient = new ManagementClient({
  tokenProvider: {
     enableCache: true,
     setCache: (token) => saveCachedToken(token),
     getCache: () => getCachedToken()
  }
});

Alternatives and current work-arounds

Currently the only solution I see is to create multiple instance of the ManagementClient to control which token is passed to it.

Additional information, if any

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAn enhancement or improvement to the SDK that could not be otherwise categorized as a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions