private async swaggerAuth(req) {
const axiosInstance: AxiosInstance = axios.create({
baseURL: `${this.config.get("KEYCLOAK_BASE_URI")}`
});
const headerName = 'x-swagger-request';
const swaggerHeaderValue = req.header(headerName);
if (!swaggerHeaderValue)
return;
let data = qs.stringify({
'client_id': 'portal-corporativo-frontend',
'username': this.config.get("KEYCLOAK_USER_NAME"),
'password': this.config.get("KEYCLOAK_USER_PASSWORD"),
'grant_type': 'password'
});
await axiosInstance
.request({
url: `/realms/digitalizacion/protocol/openid-connect/token`,
method: 'POST',
data: data
})
.then((response) => {
req.headers.token = response.data.access_token;
})
.catch((error) => {
});
}