@@ -406,13 +406,11 @@ impl Optionable for Database {
406406 . to_adbc ( )
407407 } )
408408 }
409- "databricks.auth.scopes" => {
410- self . auth_config . scopes . clone ( ) . ok_or_else ( || {
411- DatabricksErrorHelper :: invalid_state ( )
412- . message ( "option 'databricks.auth.scopes' is not set" )
413- . to_adbc ( )
414- } )
415- }
409+ "databricks.auth.scopes" => self . auth_config . scopes . clone ( ) . ok_or_else ( || {
410+ DatabricksErrorHelper :: invalid_state ( )
411+ . message ( "option 'databricks.auth.scopes' is not set" )
412+ . to_adbc ( )
413+ } ) ,
416414 "databricks.auth.token_endpoint" => {
417415 self . auth_config . token_endpoint . clone ( ) . ok_or_else ( || {
418416 DatabricksErrorHelper :: invalid_state ( )
@@ -511,7 +509,8 @@ impl adbc_core::Database for Database {
511509 } ) ?;
512510
513511 // Validate auth configuration
514- let mechanism = self . auth_config
512+ let mechanism = self
513+ . auth_config
515514 . validate ( & self . access_token )
516515 . map_err ( |e| e. to_adbc ( ) ) ?;
517516
@@ -540,7 +539,10 @@ impl adbc_core::Database for Database {
540539 ) )
541540 }
542541 AuthMechanism :: OAuth => {
543- let flow = self . auth_config . flow . expect ( "flow should be validated above" ) ;
542+ let flow = self
543+ . auth_config
544+ . flow
545+ . expect ( "flow should be validated above" ) ;
544546 match flow {
545547 AuthFlow :: TokenPassthrough => {
546548 // Token passthrough - use PersonalAccessToken provider with the provided token
@@ -552,25 +554,34 @@ impl adbc_core::Database for Database {
552554 }
553555 AuthFlow :: ClientCredentials => {
554556 // Client credentials flow (M2M) - create ClientCredentialsProvider
555- let client_id = self . auth_config . client_id . as_ref ( )
557+ let client_id = self
558+ . auth_config
559+ . client_id
560+ . as_ref ( )
556561 . expect ( "client_id should be validated above" ) ;
557- let client_secret = self . auth_config . client_secret . as_ref ( )
562+ let client_secret = self
563+ . auth_config
564+ . client_secret
565+ . as_ref ( )
558566 . expect ( "client_secret should be validated above" ) ;
559567
560568 // Default scope for M2M is "all-apis" (no offline_access since M2M has no refresh token)
561569 let scopes_str = self . auth_config . scopes . as_deref ( ) . unwrap_or ( "all-apis" ) ;
562- let scopes: Vec < String > = scopes_str. split_whitespace ( ) . map ( String :: from) . collect ( ) ;
570+ let scopes: Vec < String > =
571+ scopes_str. split_whitespace ( ) . map ( String :: from) . collect ( ) ;
563572
564573 // Create the provider (async operation - needs runtime)
565574 let provider = runtime
566- . block_on ( crate :: auth:: ClientCredentialsProvider :: new_with_full_config (
567- host,
568- client_id,
569- client_secret,
570- http_client. clone ( ) ,
571- scopes,
572- self . auth_config . token_endpoint . clone ( ) ,
573- ) )
575+ . block_on (
576+ crate :: auth:: ClientCredentialsProvider :: new_with_full_config (
577+ host,
578+ client_id,
579+ client_secret,
580+ http_client. clone ( ) ,
581+ scopes,
582+ self . auth_config . token_endpoint . clone ( ) ,
583+ ) ,
584+ )
574585 . map_err ( |e| e. to_adbc ( ) ) ?;
575586
576587 Arc :: new ( provider)
@@ -932,7 +943,10 @@ mod tests {
932943 )
933944 . unwrap ( ) ;
934945
935- assert_eq ! ( db. auth_config. client_secret, Some ( "test-secret" . to_string( ) ) ) ;
946+ assert_eq ! (
947+ db. auth_config. client_secret,
948+ Some ( "test-secret" . to_string( ) )
949+ ) ;
936950 assert_eq ! (
937951 db. get_option_string( OptionDatabase :: Other (
938952 "databricks.auth.client_secret" . into( )
@@ -951,7 +965,10 @@ mod tests {
951965 )
952966 . unwrap ( ) ;
953967
954- assert_eq ! ( db. auth_config. scopes, Some ( "all-apis offline_access" . to_string( ) ) ) ;
968+ assert_eq ! (
969+ db. auth_config. scopes,
970+ Some ( "all-apis offline_access" . to_string( ) )
971+ ) ;
955972 assert_eq ! (
956973 db. get_option_string( OptionDatabase :: Other ( "databricks.auth.scopes" . into( ) ) )
957974 . unwrap( ) ,
@@ -1564,10 +1581,13 @@ mod tests {
15641581 . unwrap ( ) ;
15651582
15661583 // Verify config is stored correctly
1567- assert_eq ! ( db. auth_mechanism, Some ( AuthMechanism :: OAuth ) ) ;
1568- assert_eq ! ( db. auth_flow, Some ( AuthFlow :: ClientCredentials ) ) ;
1569- assert_eq ! ( db. auth_client_id, Some ( "test-client-id" . to_string( ) ) ) ;
1570- assert_eq ! ( db. auth_client_secret, Some ( "test-secret" . to_string( ) ) ) ;
1584+ assert_eq ! ( db. auth_config. mechanism, Some ( AuthMechanism :: OAuth ) ) ;
1585+ assert_eq ! ( db. auth_config. flow, Some ( AuthFlow :: ClientCredentials ) ) ;
1586+ assert_eq ! ( db. auth_config. client_id, Some ( "test-client-id" . to_string( ) ) ) ;
1587+ assert_eq ! (
1588+ db. auth_config. client_secret,
1589+ Some ( "test-secret" . to_string( ) )
1590+ ) ;
15711591 }
15721592
15731593 #[ test]
@@ -1612,7 +1632,7 @@ mod tests {
16121632
16131633 // Verify custom scopes are stored
16141634 assert_eq ! (
1615- db. auth_scopes ,
1635+ db. auth_config . scopes ,
16161636 Some ( "custom-scope-1 custom-scope-2" . to_string( ) )
16171637 ) ;
16181638 }
@@ -1659,7 +1679,7 @@ mod tests {
16591679
16601680 // Verify token_endpoint override is stored
16611681 assert_eq ! (
1662- db. auth_token_endpoint ,
1682+ db. auth_config . token_endpoint ,
16631683 Some ( "https://custom.endpoint/token" . to_string( ) )
16641684 ) ;
16651685 }
0 commit comments