How get a access token in m2m actions?

I do downgrade the version of “auth0” to 3.7.2 and find the method getAccessToken, but i saw other solution your proposes and i take that code for test, but when i call the service give error for timeout, for other side is the same when i try connect with redis from auth0 action, its a capability of auth0 it can connect to extern service? or ¿i should do a config some?

my code is:

exports.onExecuteCredentialsExchange = async (event, api) => {
      const ManagementClient = require('auth0').ManagementClient;
      const jwt_decode = require('jwt-decode');

      //get current value for 'my-api-token'
      const record = api.cache.get('management-token');
      console.log("Record: ", record);
      let token = record?.value;
      let current_time = Date.now().valueOf() / 1000;

      console.log("Cached token: ", token);
      if (token != undefined) {
        var decoded = jwt_decode(token);
      }

      //Check if cached token exists/is not undefined and not expired
      if (token != undefined && decoded.exp > current_time) {
        //Initialize management client with existing token to use against Management API
        const managementWithOldToken = new ManagementClient({
          token: token,
          domain: event.secrets.DOMAIN,
        });
      
      } 
      else if (token == undefined || decoded.exp < current_time) {
        //Initialize management client with credentials
        const management = new ManagementClient({
          domain: event.secrets.DOMAIN,
          clientId: event.request.body.client_id,
          clientSecret: event.request.body.client_secret,
          audience: event.request.body.audience,
          tokenProvider: {
            enableCache: true,
            cacheTTLInSeconds: 86400
          }
        });

        //Get new access token and set it in cache
        const newToken = await management.getAccessToken();
        api.cache.set('first',newToken.slice(0,2048))
        api.cache.set('second', newToken.slice(2048,4096))
        api.cache.set('third', newToken.slice(4096))   
        const getNewToken = api.cache.get('first').value + api.cache.get('second').value + api.cache.get('third').value
        //Initialize management client with new token to use against Management API
        const managementWithNewToken = new ManagementClient({
          token: getNewToken,
          domain: event.secrets.DOMAIN,
        });      
        console.log('token success' , getNewToken)
      }
}

i saw this example @rueben.tiow