@@ -74,10 +74,11 @@ def __call_api(
7474 _preload_content = _preload_content , _request_timeout = _request_timeout
7575 )
7676 except AuthorizationException as ae :
77- if ae .token_expired :
77+ if ae .token_expired or ae .invalid_token :
78+ token_status = "expired" if ae .token_expired else "invalid"
7879 logger .warning (
79- f'authentication token has expired , refreshing the token. request= { method } { resource_path } ' )
80- # if the token has expired, lets refresh the token
80+ f'authentication token is { token_status } , refreshing the token. request= { method } { resource_path } ' )
81+ # if the token has expired or is invalid , lets refresh the token
8182 self .__force_refresh_auth_token ()
8283 # and now retry the same request
8384 return self .__call_api_no_retry (
@@ -87,20 +88,7 @@ def __call_api(
8788 _return_http_data_only = _return_http_data_only , collection_formats = collection_formats ,
8889 _preload_content = _preload_content , _request_timeout = _request_timeout
8990 )
90- elif ae .invalid_token :
91- logger .warning (
92- f'authentication token is invalid, refreshing the token. request= { method } { resource_path } ' )
93- # if the token is invalid, lets refresh the token
94- self .__force_refresh_auth_token ()
95- # and now retry the same request
96- return self .__call_api_no_retry (
97- resource_path = resource_path , method = method , path_params = path_params ,
98- query_params = query_params , header_params = header_params , body = body , post_params = post_params ,
99- files = files , response_type = response_type , auth_settings = auth_settings ,
100- _return_http_data_only = _return_http_data_only , collection_formats = collection_formats ,
101- _preload_content = _preload_content , _request_timeout = _request_timeout
102- )
103- raise ae
91+ raise ae
10492
10593 def __call_api_no_retry (
10694 self , resource_path , method , path_params = None ,
0 commit comments