diff --git a/google/auth/impersonated_credentials.py b/google/auth/impersonated_credentials.py index 4d0c4f0f1..f978b64ef 100644 --- a/google/auth/impersonated_credentials.py +++ b/google/auth/impersonated_credentials.py @@ -288,9 +288,12 @@ def sign_bytes(self, message): authed_session = AuthorizedSession(self._source_credentials) - response = authed_session.post( - url=iam_sign_endpoint, headers=headers, json=body - ) + try: + response = authed_session.post( + url=iam_sign_endpoint, headers=headers, json=body + ) + finally: + authed_session.close() if response.status_code != http_client.OK: raise exceptions.TransportError(