Skip to content

Commit d02bb50

Browse files
committed
Support custom oauth client id and rediret port range
PySQL is used by other tools/CLIs which have own oauth client id, we need to expose oauth_client_id and oauth_redirect_port_range as the connection parameters to support this customization.
1 parent 205f4b2 commit d02bb50

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/databricks/sql/auth/auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ def get_python_sql_connector_auth_provider(hostname: str, **kwargs):
8989
use_cert_as_auth=kwargs.get("_use_cert_as_auth"),
9090
tls_client_cert_file=kwargs.get("_tls_client_cert_file"),
9191
oauth_scopes=PYSQL_OAUTH_SCOPES,
92-
oauth_client_id=PYSQL_OAUTH_CLIENT_ID,
93-
oauth_redirect_port_range=PYSQL_OAUTH_REDIRECT_PORT_RANGE,
92+
oauth_client_id=kwargs.get("oauth_client_id") or PYSQL_OAUTH_CLIENT_ID,
93+
oauth_redirect_port_range=kwargs.get("oauth_redirect_port_range") if kwargs.get(
94+
"oauth_client_id") else PYSQL_OAUTH_REDIRECT_PORT_RANGE,
9495
oauth_persistence=kwargs.get("experimental_oauth_persistence"),
9596
)
9697
return get_auth_provider(cfg)

src/databricks/sql/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ def __init__(
6060
any IDP configured. This is only for interactive python applications and open a browser window.
6161
Note this is beta (private preview)
6262
63+
oauth_client_id: `str`, optional
64+
custom oauth client_id. If not specified, it will use the client_id of databricks-sql-python
65+
66+
oauth_redirect_port_range: `List[str]`, optional
67+
oauth redirect port range. This is required when custom oauth client_id `oauth_client_id` is set
68+
6369
experimental_oauth_persistence: configures preferred storage for persisting oauth tokens.
6470
This has to be a class implementing `OAuthPersistence`.
6571
When `auth_type` is set to `databricks-oauth` without persisting the oauth token in a persistence storage

0 commit comments

Comments
 (0)