diff --git a/requirements.txt b/requirements.txt index 476b12f6..389a8f13 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.23 -requests==2.26.0 \ No newline at end of file +requests==2.26.0 +pyjwt==2.6.0 \ No newline at end of file diff --git a/tb_rest_client/rest_client_base.py b/tb_rest_client/rest_client_base.py index 4f2456f0..f7e09085 100644 --- a/tb_rest_client/rest_client_base.py +++ b/tb_rest_client/rest_client_base.py @@ -14,6 +14,7 @@ # limitations under the License. # +import jwt from time import time, sleep from requests import post @@ -161,6 +162,8 @@ def __save_token(self, token_json): self.configuration.api_key["X-Authorization"] = token self.token_info['token'] = token self.token_info['refreshToken'] = refresh_token + parsed_token = jwt.decode(token, options={"verify_signature": False}) + self.token_info['exp'] = parsed_token['exp'] def __load_configuration(self): self.api_client = ApiClient(self.configuration)