Logging changes

This commit is contained in:
Pau 2022-12-20 10:50:29 +01:00
parent 7be0fdfe3c
commit bb1d88b647
1 changed files with 6 additions and 2 deletions

View File

@ -47,18 +47,20 @@ async function getClientToken() {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: `grant_type=client_credentials&client_id=${clientId}&client_secret=${clientSecret}&scope=role:app catalog:read organization:read`,
body: `grant_type=client_credentials&client_id=${clientId}&client_secret=${clientSecret}&scope=role:app catalog:read supply:read organization:read network:read`,
});
const tokenResponse = await tokenRequest.json();
console.log("Token response: ", tokenResponse);
const accessToken = tokenResponse.access_token;
let now = moment().format("YYYY-MM-DD HH:mm:ss");
let tokenExpirationDate = moment(now)
.add(tokenResponse.expires_in, "s")
.format("YYYY-MM-DD HH:mm:ss");
updateClientConfig(
clientId,
clientSecret,
@ -80,6 +82,8 @@ async function updateClientConfig(
tokenExpirationDate
) {
try {
console.log("Updating the client config with the new token...");
await models.clientConfig.update(
{
clientId: clientId,