Skip to content

Commit 3afd559

Browse files
ai: apply changes for #876 (1 review thread)
Addresses: - #3635937318 at src/databricks/sql/auth/oauth.py:67 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent f255f4a commit 3afd559

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/databricks/sql/auth/oauth.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ def refresh(self) -> Token:
6262

6363

6464
class OAuthManager:
65-
# Maximum time (in seconds) to wait for the browser OAuth redirect callback
66-
# before giving up. Without this, the local callback server would block
67-
# forever in a headless environment (e.g. a notebook/job with no browser),
68-
# making the connection appear to hang indefinitely. See issue #458.
65+
# Default maximum time (in seconds) to wait for the browser OAuth redirect
66+
# callback before giving up. Without a bound, the local callback server
67+
# would block forever in a headless environment (e.g. a notebook/job with
68+
# no browser), making the connection appear to hang indefinitely. See issue
69+
# #458. This is generous for interactive logins (slow MFA, IdP re-auth, SSO
70+
# redirects); environments that need longer can override it by passing
71+
# ``redirect_callback_timeout_seconds`` to ``__init__``.
6972
REDIRECT_CALLBACK_TIMEOUT_SECONDS = 60 * 5
7073

7174
def __init__(
@@ -74,12 +77,18 @@ def __init__(
7477
client_id: str,
7578
idp_endpoint: OAuthEndpointCollection,
7679
http_client,
80+
redirect_callback_timeout_seconds: Optional[int] = None,
7781
):
7882
self.port_range = port_range
7983
self.client_id = client_id
8084
self.redirect_port = None
8185
self.idp_endpoint = idp_endpoint
8286
self.http_client = http_client
87+
# Fall back to the class default when not overridden. Set as an instance
88+
# attribute so the rest of the flow reads a single source of truth via
89+
# ``self.REDIRECT_CALLBACK_TIMEOUT_SECONDS``.
90+
if redirect_callback_timeout_seconds is not None:
91+
self.REDIRECT_CALLBACK_TIMEOUT_SECONDS = redirect_callback_timeout_seconds
8392

8493
@staticmethod
8594
def __token_urlsafe(nbytes=32):

0 commit comments

Comments
 (0)