Nodejs скрипт для генерации токена oath2 для ansible башни - PullRequest
0 голосов
/ 29 мая 2020

Как написать сценарий node js для генерации токена oauth2 для башни ansible. Через cli:

curl -u username:password -k -X POST https://<tower-host>/api/v2/tokens/

1 Ответ

0 голосов
/ 29 мая 2020

с использованием ax ios (npm i axios) сценарий:

var axios = require('axios');
var https = require('https');

const instance = axios.create({
  httpsAgent: new https.Agent({ rejectUnauthorized: false })
});

(async () => {
  var response = await instance({
    method: 'post',
    url: 'https://api/v2/token',
    auth: { username: 'foo', password: 'bar' }
  });
  console.log('response is', response.data);
})();

объяснение агента

...