TCPWrapper error during axios inside Auth0 post login action

Hi @jasonkofogeorge,

Welcome to the Auth0 Community!

From looking at the code snippets that you shared, it seems that you are trying to get a Management API Access Token in a Post Login Action.

After testing, I have managed to get the Management API to work in Actions with the following snippet:

exports.onExecutePostLogin = async (event, api) => {
  var axios = require("axios").default;
  var options = {
    method: 'POST',
    url: 'https://YOUR_DOMAIN.REGION.auth0.com/oauth/token',
    headers: {'content-type': 'application/json'},
    data: {
      grant_type: 'client_credentials',
      client_id: 'YOUR_CLIENT_ID',
      client_secret: 'YOUR_CLIENT_SECRET',
      audience: 'https://YOUR_DOMAIN.REGION.auth0.com/api/v2/'
      
    }
  };
  axios.request(options).then(function (response) {
    console.log("access token: ",response.data.access_token);
  }).catch(function (error) {
    console.error(error);
  });
}

I recommend that you give this a try and then append your custom error handling logic on top of this example.

Alternatively, you could follow this How can I use the Management API in Actions? FAQ which describes how to use the Management API with the Management Client.

Hoped this helps!

Please let me know if there are any other questions. I’d be glad to help.

Thank you.