googleapis / google-auth-library-python

Google Auth Python Library
https://googleapis.dev/python/google-auth/latest/
Apache License 2.0
755 stars 303 forks source link

ImportError in google.oauth2.id_token #1455

Closed B3QL closed 5 months ago

B3QL commented 5 months ago

Environment details

Steps to reproduce

  1. Install google-auth
  2. Import google.oauth2.id_token module

Hi folks, it looks like google.oauth2.id_token has an import time dependency of google.auth.transport.requests https://github.com/googleapis/google-auth-library-python/blob/main/google/oauth2/id_token.py#L65

which requires a requests package https://github.com/googleapis/google-auth-library-python/blob/main/google/auth/transport/requests.py#L25

that's not defined as a google-auth dependency. https://github.com/googleapis/google-auth-library-python/blob/main/setup.py#L22

The call to google.auth.transport.requests is only made once in https://github.com/googleapis/google-auth-library-python/blob/main/google/oauth2/id_token.py#L285 so the possible solution will be to move the import to runtime.

clundin25 commented 5 months ago

Thank you for pointing this out. Yes the code is not following the existing pattern of a runtime import if a request object is not passed in.