fix(basic.gblib): update ChatServices.ts #420

Closed
eltociear wants to merge 2540 commits from patch-1 into main
Showing only changes of commit 84858db975 - Show all commits

View file

@ -611,8 +611,12 @@ export class GBVMService extends GBService {
// Auto update Bearar authentication for the first token.
const expiresOn = new Date(global[tokenName + "_expiresOn"]);
if (expiresOn.getTime() < new Date().getTime() || firstTime) {
const expiration = expiresOn.getTime() - (10 * 60 * 1000);
// Expires token 10min. before or if it the first time, load it.
if (expiration < new Date().getTime() || firstTime) {
console.log ('Expired. Refreshing token...');
const {token, expiresOn} = await sys.getCustomToken({pid, tokenName});
global[tokenName] = token;