FetchError when trying to use the management API

I’m getting a weird error when trying to do anything via the management API via the Node SDK. Specifically:

FetchError: The request failed and the interceptors did not return an alternative response

Here’s my code.

	const auth0 = new ManagementClient({
		domain: '*****.uk.auth0.com',
		clientId: '*****',
		clientSecret: '*****',
	});
	await auth0.users.update(
		{id: 'auth0|*****'},
		{app_metadata: {foo: 'bar'}}
	);

I’ve read every topic on this error and nothing has helped. Specifically:

  • I’m not using dd-trace, a package that some said caused the problem
  • I’m not prefixing my domain with a protocol
  • My credentials are correct

One thing I would like to confirm is where I should get my client ID and secret from. I’m currently getting them from Applications > API Explorer Application. I assume I don’t need to do anything else with this built-in application in order to be able to use the management API. Under “APIs” the management API is listed, and it is authorised.

I am hosted on Cloudflare Workers.

Have I no option but to use the REST API rather than the Node SDK?

Hi @kkrp1

Thanks for posting your question on the community!

Have you also tried initializing the management client using the API token of the Management API?

import { ManagementClient } from 'auth0';

var management = new ManagementClient({
  domain: '{YOUR_TENANT_AND REGION}.auth0.com',
  token: '{YOUR_API_V2_TOKEN}',
});

Also, as far as I know regarding the NodeJS, the clientID and clientSecret parameters should be populated with the values from a M2M application used by your application to communicate with the Management API.

Let me know if you have any other questions or updates!

Kind Regards,
Nik

Hi Nik,

Thanks for your reply. I will try the token approach you suggest, but is there any reason the client/secret approach shouldn’t work? The docs suggest it should.

The API Explorer is an M2M - it’s auto-created by Auth0, so I figured this was the place to get the client/secret from.