auth0 / node-auth0

Node.js client library for the Auth0 platform.
MIT License
628 stars 307 forks source link

TokenProviderMiddleware does not use custom fetch() #937

Closed denisw closed 11 months ago

denisw commented 11 months ago

Checklist

Description

When I pass a custom fetch implementation to the ManagementClient constructor, then it is not forwarded to and used by the TokenProviderMiddleware created in the ManagementClient constructor.

Reproduction

import * as auth0 from 'auth0';

function customFetch(url, init) {
  console.log(url);
  return fetch(url, init);
}

const client = new auth0.ManagementClient({
  domain: 'https://example.us.auth0.com',
  clientId: 'dummy',
  clientSecret: 'dummy',
  fetch: customFetch,
});

await client.users.getAll({});

When running the script above, we should see the URL of the token endpoint to be printed, but because the TokenProviderMiddleware uses the global fetch and not the custom one, it doesn't.

Additional context

No response

node-auth0 version

4.0.0

Node.js version

18.17.0

frederikprijck commented 11 months ago

Thanks, I can see what's causing that. I will look into providing a fix.

frederikprijck commented 11 months ago

Fixed and released as 4.0.1.

Thanks for reporting, feel free to let us know if there would be any other issues.

denisw commented 11 months ago

Wow, that was quick! Thank you. 🙂