Skip to content

Commit 9cd6742

Browse files
authored
fix: Conditionally import requests only if no request was passed by the caller. (#1456)
This resolves https://togithub.com/googleapis/google-auth-library-python/issues/1455. The repo-wide pattern is to only import the requests module at runtime as a fallback.
1 parent c33f308 commit 9cd6742

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

google/oauth2/id_token.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
from google.auth import environment_vars
6363
from google.auth import exceptions
6464
from google.auth import jwt
65-
import google.auth.transport.requests
6665

6766

6867
# The URL that provides public certificates for verifying ID tokens issued
@@ -282,6 +281,8 @@ def fetch_id_token_credentials(audience, request=None):
282281

283282
# Create a request object if not provided.
284283
if not request:
284+
import google.auth.transport.requests
285+
285286
request = google.auth.transport.requests.Request()
286287

287288
if _metadata.ping(request):

system_tests/secrets.tar.enc

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)