Closed clundin25 closed 1 year ago
I verified that this is failing as well:
import google.auth
import google.auth.transport.requests
import google.auth.impersonated_credentials
# gcloud auth application-default login --impersonate-service-account=...
creds, _project_id = google.auth.default(scopes=["https://www.googleapis.com/auth/cloud-platform"])
assert isinstance(creds, google.auth.impersonated_credentials.Credentials), "gcloud login with impersonated creds required"
request = google.auth.transport.requests.Request()
creds.refresh(request)
assert creds.token
assert not creds.expired
id_creds = google.auth.impersonated_credentials.IDTokenCredentials(creds, 'foo', include_email=True)
id_creds.refresh(request)
assert id_creds.token
assert not id_creds.expired
Same as in #1323, with export TZ=America/New_York
the id token is considered expired immediately and the last assert fails.
And confirming that when I change the code to utcfromtimestamp
then the test case passes.
Awesome ! @juzna since you've already done all the hard work, do you want to open a PR for this? :)
If not I will, and will give you credit
ID tokens had an issue where the
fromtimestamp
API was used instead ofutcfromtimestamp
. Ref: https://github.com/googleapis/google-auth-library-python/issues/1323.It appears that
impersonated_credentials.py
uses the same API, and is likely impacted by the same issue.google/auth/impersonated_credentials.py
should be updated to useutcfromtimestamp
instead offromtimestamp
.