This repository was archived by the owner on Mar 6, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
google/auth/compute_engine Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4545 environment_vars .GCE_METADATA_ROOT , "metadata.google.internal"
4646 )
4747
48- GCE_MDS_HOSTS = ["metadata.google.internal" , "169.254.169.254" ]
48+ _GCE_DEFAULT_MDS_IP = "169.254.169.254"
49+ _GCE_MDS_HOSTS = ["metadata.google.internal" , _GCE_DEFAULT_MDS_IP ]
4950
5051
5152def _get_metadata_root (use_mtls ):
@@ -58,7 +59,7 @@ def _get_metadata_ip_root(use_mtls):
5859 """Returns the metadata server IP root URL."""
5960 scheme = "https" if use_mtls else "http"
6061 return "{}://{}" .format (
61- scheme , os .getenv (environment_vars .GCE_METADATA_IP , "169.254.169.254" )
62+ scheme , os .getenv (environment_vars .GCE_METADATA_IP , _GCE_DEFAULT_MDS_IP )
6263 )
6364
6465
@@ -123,10 +124,12 @@ def _prepare_request_for_mds(request, use_mtls=False):
123124 Args:
124125 request (google.auth.transport.Request): A callable used to make
125126 HTTP requests.
127+ use_mtls (bool): Whether to use mTLS for the request.
126128
127129 Returns:
128- google.auth.transport.Request: Request
129- object to use.
130+ google.auth.transport.Request: A request object to use.
131+ If mTLS is enabled, this will be a new request object with mTLS session configured.
132+ Otherwise, it will be the same as the input request.
130133 """
131134 if use_mtls :
132135 request = requests .Request (_mtls .create_session ())
You can’t perform that action at this time.
0 commit comments