Skip to content

Commit a6763ee

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

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

databricks/sdk/credentials_provider.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,17 @@ 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+
# Metadata URL usually points to localhost, and the requests package doesn't exclude localhost from proxies by default
688+
"no_proxy": "localhost,127.0.0.1"
689+
})
685690
json_resp: dict[str, Union[str, float]] = resp.json()
686691
access_token = json_resp.get("access_token", None)
687692
if access_token is None:

0 commit comments

Comments
 (0)