Skip to content

Commit

Permalink
fix: access token logic more failsave
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikZed committed Oct 24, 2023
1 parent 4a45017 commit bbef585
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/integration-kencove-api/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ export class KencoveApiClient {
decoded &&
decoded.exp &&
/**
* is the first date after the second date?
* The token is normally valid 1h, but we want to refresh
* 30 minutes before expiration.
*/
isAfter(new Date(decoded.exp * 1000), new Date())
isAfter(
new Date(decoded.exp * 1000 - 30 * 60 * 1000),
new Date(),
)
// isAfter(new Date(decoded.exp * 1000), new Date())
) {
return this.jwt;
}
}

try {
this.logger.debug("Requesting new access token");
const response = await axios.request({
method: "post",
url: this.app.tokenEndpoint,
Expand Down

1 comment on commit bbef585

@vercel
Copy link

@vercel vercel bot commented on bbef585 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.