@@ -236,12 +236,15 @@ def kernel_auth_kwargs(
236236 # authenticate as databricks-sql-connector, breaking parity with
237237 # the Thrift path (which authenticates as databricks-sql-python).
238238 #
239- # client_id + scopes + redirect_port are coupled per OAuth app —
240- # each app registers its own redirect URI — so all three are
241- # resolved together: an explicit caller value wins; otherwise the
242- # connector's registered databricks-sql-python (or azure) bundle is
243- # used, mirroring the defaults get_python_sql_connector_auth_provider
244- # applies on the Thrift path.
239+ # client_id + redirect_port are coupled per OAuth app — each app
240+ # registers its own redirect URI — so both are resolved together:
241+ # an explicit caller value wins; otherwise the connector's
242+ # registered databricks-sql-python (or azure) bundle is used,
243+ # mirroring the defaults get_python_sql_connector_auth_provider
244+ # applies on the Thrift path. scopes are NOT caller-overridable:
245+ # the Thrift path hardcodes PYSQL_OAUTH_SCOPES for U2M (a caller's
246+ # oauth_scopes kwarg is never read there), so we forward the same
247+ # fixed scopes here to keep the two backends in parity.
245248 #
246249 # Only the redirect PORT is routable into the kernel: it derives
247250 # http://localhost:{port}, with scheme/host/path fixed. The
@@ -263,7 +266,12 @@ def kernel_auth_kwargs(
263266 else PYSQL_OAUTH_REDIRECT_PORT_RANGE
264267 )
265268 redirect_port = opts .get ("oauth_redirect_port" )
266- scopes = _normalize_scopes (opts .get ("oauth_scopes" ))
269+ # Validate any caller-supplied oauth_scopes (a bad type is still a
270+ # caller error worth flagging) but do NOT forward it: the Thrift
271+ # path hardcodes PYSQL_OAUTH_SCOPES for U2M, so we do the same for
272+ # parity rather than letting the kernel path honor an override the
273+ # other backend silently ignores.
274+ _normalize_scopes (opts .get ("oauth_scopes" ))
267275 kwargs = {
268276 "auth_type" : "oauth-u2m" ,
269277 "client_id" : client_id or default_client_id ,
@@ -272,9 +280,7 @@ def kernel_auth_kwargs(
272280 if client_id and redirect_port is not None
273281 else default_port_range [0 ]
274282 ),
275- "oauth_scopes" : (
276- scopes if scopes is not None else list (PYSQL_OAUTH_SCOPES )
277- ),
283+ "oauth_scopes" : list (PYSQL_OAUTH_SCOPES ),
278284 }
279285 if federation_client_id :
280286 kwargs ["identity_federation_client_id" ] = federation_client_id
0 commit comments