Skip to content

Commit 05e841a

Browse files
author
haroldfabla2-hue
committed
fix: add timeout to requests calls in oauth.py
- Add timeout=60 to requests.post() in retrieve_token() (line 209) - Add timeout=60 to requests.get() in get_azure_entra_id_workspace_endpoints() (line 548) - Add timeout=60 to requests.post() in PATOAuthTokenExchange.refresh() (line 916) This prevents indefinite hangs when OAuth endpoints are unreachable or slow, matching the SDK's default http_timeout_seconds of 60 seconds. Resolves #1338
1 parent 9aa5f64 commit 05e841a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

databricks/sdk/oauth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def retrieve_token(
206206
auth = requests.auth.HTTPBasicAuth(client_id, client_secret)
207207
else:
208208
auth = IgnoreNetrcAuth()
209-
resp = requests.post(token_url, params, auth=auth, headers=headers)
209+
resp = requests.post(token_url, params, auth=auth, headers=headers, timeout=60)
210210
if not resp.ok:
211211
if resp.headers["Content-Type"].startswith("application/json"):
212212
err = resp.json()
@@ -545,7 +545,7 @@ def get_azure_entra_id_workspace_endpoints(
545545
"""
546546
# In Azure, this workspace endpoint redirects to the Entra ID authorization endpoint
547547
host = _fix_host_if_needed(host)
548-
res = requests.get(f"{host}/oidc/oauth2/v2.0/authorize", allow_redirects=False)
548+
res = requests.get(f"{host}/oidc/oauth2/v2.0/authorize", allow_redirects=False, timeout=60)
549549
real_auth_url = res.headers.get("location")
550550
if not real_auth_url:
551551
return None
@@ -913,7 +913,7 @@ def refresh(self) -> Token:
913913
if self.authorization_details:
914914
params["authorization_details"] = self.authorization_details
915915

916-
resp = requests.post(token_exchange_url, params)
916+
resp = requests.post(token_exchange_url, params, timeout=60)
917917
if not resp.ok:
918918
if resp.headers["Content-Type"].startswith("application/json"):
919919
err = resp.json()

0 commit comments

Comments
 (0)