Management API returns 401 from quickstart sample

I have finally gotten a round-trip to work.

The first step is to get the token as per Applications->API->Test with the “Auth0 Management API (Test Application)” selected (from the dropdown) as the application to test.

This uses the client_id and client_secret of the Auth0 Management API test application.

With this token in-hand, I then used the recipe from Get Management API Access Tokens for Production (provided by @tyf upthread).

Scrolling that link down, I see the vital new information – the url passed in the request that uses the token just collected.

Here is the axios code fragment that finally worked for me:

var axios = require("axios");

const options = { 
  method: "GET",
  url: `https://${auth0Domain}/api/v2/users`,
  headers: {'authorization': `Bearer ${localToken}`}
};

axios(options)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });

I still need to do further experimentation to discover the permutations of client_id/client_secret, audience, and subsequent url that work.

At least I’m finally able to collect users using the “Auth0 Management API”.

1 Like