diff --git a/google/auth/compute_engine/credentials.py b/google/auth/compute_engine/credentials.py index 30ffb162b..930d88617 100644 --- a/google/auth/compute_engine/credentials.py +++ b/google/auth/compute_engine/credentials.py @@ -389,7 +389,7 @@ def _call_metadata_identity_endpoint(self, request): six.raise_from(new_exc, caught_exc) _, payload, _, _ = jwt._unverified_decode(id_token) - return id_token, datetime.datetime.fromtimestamp(payload["exp"]) + return id_token, datetime.datetime.utcfromtimestamp(payload["exp"]) def refresh(self, request): """Refreshes the ID token. diff --git a/tests/compute_engine/test_credentials.py b/tests/compute_engine/test_credentials.py index f56bada2d..507fea9fc 100644 --- a/tests/compute_engine/test_credentials.py +++ b/tests/compute_engine/test_credentials.py @@ -770,7 +770,7 @@ def test_get_id_token_from_metadata( } assert cred.token == SAMPLE_ID_TOKEN - assert cred.expiry == datetime.datetime.fromtimestamp(SAMPLE_ID_TOKEN_EXP) + assert cred.expiry == datetime.datetime.utcfromtimestamp(SAMPLE_ID_TOKEN_EXP) assert cred._use_metadata_identity_endpoint assert cred._signer is None assert cred._token_uri is None