GoogleCloudPlatform / alloydb-python-connector

A Python library for connecting securely to your AlloyDB instances.
Apache License 2.0
25 stars 6 forks source link

refactor: use google.auth TokenState for credentials validity #321

Closed jackwotherspoon closed 1 month ago

jackwotherspoon commented 1 month ago

In the google.auth package, it is now recommended to use .token_state over .valid for checking validity of credentials.

Token state gives more information such as if token is stale, expired, invalid etc.

.valid is now marked as deprecated (code):

@property
def valid(self):
    """Checks the validity of the credentials.

    This is True if the credentials have a :attr:`token` and the token
    is not :attr:`expired`.

    .. deprecated:: v2.24.0
      Prefer checking :attr:`token_state` instead.
    """
    return self.token is not None and not self.expired

Closes #286

Should also unblock #245