Skip to content

Commit

Permalink
Updated token renewal strategy to ask for a new token if the existing…
Browse files Browse the repository at this point in the history
… token expires in the next 60 secs (#96)
  • Loading branch information
antikus authored Aug 15, 2023
1 parent 489d547 commit 78ac26c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class AccessToken {
) {}

get isExpired() {
const delta = Date.now() - this.createdOn;

// experiesIn stored in seconds
return delta / 1000 >= this.experiesIn;
const delta = (Date.now() - this.createdOn) / 1000;

// anticipate access token expiration by 60 seconds
return delta + 60 >= this.experiesIn;
}
}

Expand Down

0 comments on commit 78ac26c

Please sign in to comment.