Logging changes
This commit is contained in:
parent
7be0fdfe3c
commit
bb1d88b647
8
index.js
8
index.js
|
@ -47,18 +47,20 @@ async function getClientToken() {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"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();
|
const tokenResponse = await tokenRequest.json();
|
||||||
|
|
||||||
|
console.log("Token response: ", tokenResponse);
|
||||||
|
|
||||||
const accessToken = tokenResponse.access_token;
|
const accessToken = tokenResponse.access_token;
|
||||||
let now = moment().format("YYYY-MM-DD HH:mm:ss");
|
let now = moment().format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
|
||||||
let tokenExpirationDate = moment(now)
|
let tokenExpirationDate = moment(now)
|
||||||
.add(tokenResponse.expires_in, "s")
|
.add(tokenResponse.expires_in, "s")
|
||||||
.format("YYYY-MM-DD HH:mm:ss");
|
.format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
|
||||||
updateClientConfig(
|
updateClientConfig(
|
||||||
clientId,
|
clientId,
|
||||||
clientSecret,
|
clientSecret,
|
||||||
|
@ -80,6 +82,8 @@ async function updateClientConfig(
|
||||||
tokenExpirationDate
|
tokenExpirationDate
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
console.log("Updating the client config with the new token...");
|
||||||
await models.clientConfig.update(
|
await models.clientConfig.update(
|
||||||
{
|
{
|
||||||
clientId: clientId,
|
clientId: clientId,
|
||||||
|
|
Loading…
Reference in New Issue