Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions google/auth/transport/urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@
try:
import urllib3 # type: ignore
import urllib3.exceptions # type: ignore
from packaging import version # type: ignore
except ImportError as caught_exc: # pragma: NO COVER
raise ImportError(
"The urllib3 library is not installed from please install the "
"urllib3 package to use the urllib3 transport."
""
f"Error: {caught_exc}."
" The 'google-auth' library requires the extras installed "
"for urllib3 network transport."
"\n"
"Please install the necessary dependencies using pip:\n"
" pip install google-auth[urllib3]\n"
"\n"
"(Note: Using '[urllib3]' ensures the specific dependencies needed for this feature are installed. "
"We recommend running this command in your virtual environment.)"
) from caught_exc

from packaging import version # type: ignore

from google.auth import environment_vars
from google.auth import exceptions
Expand Down Expand Up @@ -414,7 +422,7 @@ def urlopen(self, method, url, body=None, headers=None, **kwargs):
body=body,
headers=headers,
_credential_refresh_attempt=_credential_refresh_attempt + 1,
**kwargs
**kwargs,
)

return response
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"reauth": "pyu2f>=0.1.5",
"enterprise_cert": ["cryptography", "pyopenssl"],
"pyjwt": ["pyjwt>=2.0", "cryptography>=38.0.3"],
"urllib3": ["urllib3", "packaging"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does user know to install this extra?

Maybe update the error msg in the try catch and tell users about this extra.

Also move packaging into the try?

from packaging import version # type: ignore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

installing dependency like pip install google-auth[urllib3] should install all the dependencies defined for urlllib3. I was thinking about updating error message, however I saw similar error in other modules, but this is definitely confusing. let me update the message to include google-auth[urllib3] command to avoid user installing directly from pip.

}

with io.open("README.rst", "r") as fh:
Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.