Skip to content

Commit 5a0fd5c

Browse files
committed
hide sensitive information
1 parent 446c8e7 commit 5a0fd5c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

google/auth/transport/requests.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import numbers
2222
import os
2323
import time
24+
import json
2425

2526
try:
2627
import requests
@@ -182,10 +183,18 @@ def __call__(
182183
google.auth.exceptions.TransportError: If any exception occurred.
183184
"""
184185
try:
185-
_LOGGER.debug("Making request: %s %s", method, url)
186+
_LOGGER.debug("Making request...", extra={"httpRequest": {"method": method, "url": url, "body": body.decode("utf-8"), "headers": headers}})
186187
response = self.session.request(
187188
method, url, data=body, headers=headers, timeout=timeout, **kwargs
188189
)
190+
_SENSITIVE_LOG_FIELDS = ["access_token", "id_token"]
191+
192+
test = response.json()
193+
for field in _SENSITIVE_LOG_FIELDS:
194+
if field in test:
195+
test[field] = " --TOKEN REDACTED --"
196+
197+
_LOGGER.debug("Response received...", extra={"httpResponse": test})
189198
return _Response(response)
190199
except requests.exceptions.RequestException as caught_exc:
191200
new_exc = exceptions.TransportError(caught_exc)

0 commit comments

Comments
 (0)