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: {
|
||||
"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,
|
||||
|
|
Loading…
Reference in New Issue