auth0 / node-auth0

Node.js client library for the Auth0 platform.
MIT License
639 stars 309 forks source link

Can I custom access token retrieval Process in ManagementClient? #1050

Open cm-iwata opened 2 weeks ago

cm-iwata commented 2 weeks ago

Checklist

Describe the problem you'd like to have solved

I'm trying to implement a process to call the Management API on AWS Lambda.

Since Lambda's execution environment scales horizontally, I want to cache the access token in SSM Parameter Store and share it across Lambda execution environments.

It seems that PR #793 allowed replacing the access token retrieval process with a custom-implemented function. I tried to implement a process using SSM Parameter Store utilizing this feature. However, in the latest SDK version 4.11, the token constructor argument of ManagementClient is typed as string, making it impossible to replace it with a custom-implemented function.

https://github.com/auth0/node-auth0/blob/9a5ca5cb954571bc169d86cfa1606da9f157137b/src/management/management-client-options.ts#L8-L11

I couldn't find the reason why the modification in #793 was reverted. Is it currently not possible to customize the access token retrieval process?

Describe the ideal solution

same as #793

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

Alternatives and current workarounds

No response

Additional context

No response