Closed kasium closed 10 months ago
this can be fixed by replacing datetime.datetime.utcnow()
with datetime.datetime.now(datetime.timezone.utc)
, see
https://docs.python.org/3.12/library/datetime.html#datetime.datetime.utcnow
it looks like we cannot simply replace datetime.datetime.utcnow()
with datetime.datetime.now(datetime.timezone.utc)
, since utcnow
is offset-naive (no timezone) but now
is offset-aware (has timezone). It's very common to compare the token expiry in auth lib itself as well as gcloud, if we simply switch the type, the comparison fails.
I guess you can then just remove the tzinfo afterwards like ".replace(tzinfo=None)"
@kasium yep, that sounds like the only way. Thanks!
Environment details
google-auth
version: 2.9.1Issue
Here is the related code
https://github.com/googleapis/google-auth-library-python/blob/d2ab3afdb567850121fec7de1d86fb5fb0fa80ed/google/auth/_helpers.py#L89-L95