Skip to content

Commit

Permalink
fix: Conditionally import requests only if no request was passed by t…
Browse files Browse the repository at this point in the history
…he 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.
  • Loading branch information
clundin25 authored Jan 19, 2024
1 parent c33f308 commit 9cd6742
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion google/oauth2/id_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
from google.auth import environment_vars
from google.auth import exceptions
from google.auth import jwt
import google.auth.transport.requests


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

# Create a request object if not provided.
if not request:
import google.auth.transport.requests

request = google.auth.transport.requests.Request()

if _metadata.ping(request):
Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.

0 comments on commit 9cd6742

Please sign in to comment.