diff --git a/clearml/backend_api/config/default/api.conf b/clearml/backend_api/config/default/api.conf index 554348d4..8746dbbf 100644 --- a/clearml/backend_api/config/default/api.conf +++ b/clearml/backend_api/config/default/api.conf @@ -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 } } diff --git a/clearml/backend_api/session/session.py b/clearml/backend_api/session/session.py index f9d41013..490821eb 100644 --- a/clearml/backend_api/session/session.py +++ b/clearml/backend_api/session/session.py @@ -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)