cloud-sql-python-connector
cloud-sql-python-connector copied to clipboard
Replace`credentials.valid` check for `credentials.token_state`
New best practice for checking validity of credentials is no longer credentials.valid
which is now deprecated (as of google-auth v2.24.0). Instead the google-auth folks recommend using credentials.token_state
All instances of the following: https://github.com/GoogleCloudPlatform/cloud-sql-python-connector/blob/4d5e2b3cc03ed7ceb4c5463fd373a90c00f871dd/google/cloud/sql/connector/client.py#L116-L118
Should be replaced to:
from google.auth.credentials import TokenState
# ...
if not self._credentials.token_state == TokenState.FRESH:
self._credentials.refresh(google.auth.transport.requests.Request())