Skip to content

Commit efcf9ae

Browse files
committed
[Fix] Exclude localhost from hitting proxies for metadata service requests
1 parent 4bcfb0a commit efcf9ae

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

databricks/sdk/credentials_provider.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,18 @@ def __init__(self, cfg: 'Config'):
676676
self.host = cfg.host
677677

678678
def refresh(self) -> Token:
679-
resp = requests.get(self.url,
680-
timeout=self._metadata_service_timeout,
681-
headers={
682-
self.METADATA_SERVICE_VERSION_HEADER: self.METADATA_SERVICE_VERSION,
683-
self.METADATA_SERVICE_HOST_HEADER: self.host
684-
})
679+
resp = requests.get(
680+
self.url,
681+
timeout=self._metadata_service_timeout,
682+
headers={
683+
self.METADATA_SERVICE_VERSION_HEADER: self.METADATA_SERVICE_VERSION,
684+
self.METADATA_SERVICE_HOST_HEADER: self.host
685+
},
686+
proxies={
687+
# Explicitly exclude localhost from being proxied. This is necessary
688+
# for Metadata URLs which typically point to localhost.
689+
"no_proxy": "localhost,127.0.0.1"
690+
})
685691
json_resp: dict[str, Union[str, float]] = resp.json()
686692
access_token = json_resp.get("access_token", None)
687693
if access_token is None:

0 commit comments

Comments
 (0)