File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,7 +78,12 @@ def refresh(self) -> dict:
7878
7979 response = requests .post (
8080 url , json = payload , headers = self ._generate_headers ())
81- handle_error (response )
81+
82+ # if refresh token is also expired, authenticate again:
83+ if response .status_code == 400 :
84+ return self .authenticate ()
85+ else :
86+ handle_error (response )
8287
8388 auth_data = response .json ()
8489
@@ -104,4 +109,4 @@ def is_expired(self) -> bool:
104109 :return: True if the access token is expired, otherwise False.
105110 :rtype: bool
106111 """
107- return time .time () > self ._expires_at
112+ return time .time () >= self ._expires_at
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ def _refresh_token_if_expired(self) -> None:
147147
148148 :raises APIException: an api exception with message and error type code
149149 """
150- if (self ._auth_service .is_expired ()):
150+ if (self ._auth_service .is_expired ()):
151151 # try to refresh. if refresh token has expired, reauthenticate
152152 try :
153153 self ._auth_service .refresh ()
@@ -182,7 +182,7 @@ def _generate_user_agent(self) -> str:
182182 :rtype: str
183183 """
184184 # get the first 10 chars of the client id
185- client_id_truncated = self ._auth_service ._client_id [:10 ]
185+ client_id_truncated = self ._auth_service ._client_id [:10 ]
186186
187187 return f'datacrunch-python-v{ self ._version } -{ client_id_truncated } '
188188
You can’t perform that action at this time.
0 commit comments