Closed taep96 closed 2 years ago
If you use account.use() it will automatically refresh the token if needed
Here is code fragment that does it:
async use() {
if (await this.checkValidToken()) {
return this.accessToken;
} else {
if (this.login_username && this.login_password) {
try {
await this.refresh();
return this.accessToken;
} catch (e) {
await this.Login();
return this.accessToken;
}
} else {
await this.refresh();
return this.accessToken;
}
}
}
If the token is valid it returns it If the token is invalid it will first refresh it. Than if it fails login with account credentials. If no login credentials are provided It will also refresh it.
If you have any questions/suggestions feel free to ask.
Do I need to refresh tokens myself or does the package do it for me?