Allow requesting custom token expiration using the api.auth.req_token_expiration_sec configuration setting

This commit is contained in:
allegroai 2023-01-19 11:20:08 +02:00
parent 88259094ac
commit 8cb4ac2acb
2 changed files with 9 additions and 1 deletions

View File

@ -54,5 +54,9 @@
auth {
# When creating a request, if token will expire in less than this value, try to refresh the token
token_expiration_threshold_sec = 360
# token expiration time in seconds to request from the server. if not specified,
# server will set the default expiration
req_token_expiration_sec: null
}
}

View File

@ -139,6 +139,8 @@ class Session(TokenManager):
"auth.token_expiration_threshold_sec", 60
)
req_token_expiration_sec = self.config.get("api.auth.req_token_expiration_sec", None)
self._verbose = verbose if verbose is not None else ENV_VERBOSE.get()
self._logger = logger
if self._verbose and not self._logger:
@ -165,7 +167,9 @@ class Session(TokenManager):
# init the token manager
super(Session, self).__init__(
token_expiration_threshold_sec=token_expiration_threshold_sec, **kwargs
token_expiration_threshold_sec=token_expiration_threshold_sec,
req_token_expiration_sec=req_token_expiration_sec,
**kwargs
)
host = host or self.get_api_server_host(config=self.config)