@@ -208,11 +208,11 @@ class _OAuth2TokenCache(metaclass=abc.ABCMeta):
208
208
"""
209
209
210
210
@abc .abstractmethod
211
- def get_token_from_cache (self , host : Optional [str ]) -> Optional [str ]:
211
+ def get_token_from_cache (self , key : Optional [str ]) -> Optional [str ]:
212
212
pass
213
213
214
214
@abc .abstractmethod
215
- def store_token_to_cache (self , host : Optional [str ], token : str ) -> None :
215
+ def store_token_to_cache (self , key : Optional [str ], token : str ) -> None :
216
216
pass
217
217
218
218
@@ -224,11 +224,11 @@ class _OAuth2TokenInMemoryCache(_OAuth2TokenCache):
224
224
def __init__ (self ) -> None :
225
225
self ._cache : Dict [Optional [str ], str ] = {}
226
226
227
- def get_token_from_cache (self , host : Optional [str ]) -> Optional [str ]:
228
- return self ._cache .get (host )
227
+ def get_token_from_cache (self , key : Optional [str ]) -> Optional [str ]:
228
+ return self ._cache .get (key )
229
229
230
- def store_token_to_cache (self , host : Optional [str ], token : str ) -> None :
231
- self ._cache [host ] = token
230
+ def store_token_to_cache (self , key : Optional [str ], token : str ) -> None :
231
+ self ._cache [key ] = token
232
232
233
233
234
234
class _OAuth2KeyRingTokenCache (_OAuth2TokenCache ):
@@ -248,18 +248,18 @@ def is_keyring_available(self) -> bool:
248
248
return self ._keyring is not None \
249
249
and not isinstance (self ._keyring .get_keyring (), self ._keyring .backends .fail .Keyring )
250
250
251
- def get_token_from_cache (self , host : Optional [str ]) -> Optional [str ]:
251
+ def get_token_from_cache (self , key : Optional [str ]) -> Optional [str ]:
252
252
try :
253
- return self ._keyring .get_password (host , "token" )
253
+ return self ._keyring .get_password (key , "token" )
254
254
except self ._keyring .errors .NoKeyringError as e :
255
255
raise trino .exceptions .NotSupportedError ("Although keyring module is installed no backend has been "
256
256
"detected, check https://pypi.org/project/keyring/ for more "
257
257
"information." ) from e
258
258
259
- def store_token_to_cache (self , host : Optional [str ], token : str ) -> None :
259
+ def store_token_to_cache (self , key : Optional [str ], token : str ) -> None :
260
260
try :
261
261
# keyring is installed, so we can store the token for reuse within multiple threads
262
- self ._keyring .set_password (host , "token" , token )
262
+ self ._keyring .set_password (key , "token" , token )
263
263
except self ._keyring .errors .NoKeyringError as e :
264
264
raise trino .exceptions .NotSupportedError ("Although keyring module is installed no backend has been "
265
265
"detected, check https://pypi.org/project/keyring/ for more "
@@ -382,13 +382,13 @@ def _get_token(self, token_server: str, response: Response, **kwargs: Any) -> st
382
382
383
383
raise exceptions .TrinoAuthError ("Exceeded max attempts while getting the token" )
384
384
385
- def _get_token_from_cache (self , host : Optional [str ]) -> Optional [str ]:
385
+ def _get_token_from_cache (self , key : Optional [str ]) -> Optional [str ]:
386
386
with self ._token_lock :
387
- return self ._token_cache .get_token_from_cache (host )
387
+ return self ._token_cache .get_token_from_cache (key )
388
388
389
- def _store_token_to_cache (self , host : Optional [str ], token : str ) -> None :
389
+ def _store_token_to_cache (self , key : Optional [str ], token : str ) -> None :
390
390
with self ._token_lock :
391
- self ._token_cache .store_token_to_cache (host , token )
391
+ self ._token_cache .store_token_to_cache (key , token )
392
392
393
393
@staticmethod
394
394
def _determine_host (url : Optional [str ]) -> Any :
0 commit comments