Fix JWT token renewal condition

Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
magic_rb 2024-06-14 15:15:33 +02:00 committed by mergify[bot]
parent 383d759cce
commit aaab03e1da

View file

@ -73,7 +73,7 @@ class JWTToken(RepoToken):
# return list(map(lambda installation: create_installation_access_token(installation['id']).json()["token"], installations)) # return list(map(lambda installation: create_installation_access_token(installation['id']).json()["token"], installations))
def get(self) -> str: def get(self) -> str:
if datetime.now(tz=UTC) - self.expiration > self.lifetime * 0.8: if self.expiration - datetime.now(tz=UTC) < self.lifetime * 0.2:
self.token, self.expiration = JWTToken.generate_token( self.token, self.expiration = JWTToken.generate_token(
self.app_id, self.app_private_key, self.lifetime self.app_id, self.app_private_key, self.lifetime
) )