@@ -30,10 +30,9 @@ async fn main() -> mongodb::error::Result<()> {
3030 . username ( "<username>" . to_owned ( ) )
3131 . mechanism ( AuthMechanism :: MongoDbOidc )
3232 . mechanism_properties (
33- doc ! { "ENVIRONMENT" : "azure" , "TOKEN_RESOURCE" : "<audience>" }
33+ doc ! { "ENVIRONMENT" : "azure" , "TOKEN_RESOURCE" : "<audience>" }
3434 )
35- . build ( )
36- . into ( ) ;
35+ . build ( ) ;
3736
3837 client_options. credential = Some ( credential) ;
3938 let client = Client :: with_options ( client_options) ?;
@@ -48,10 +47,9 @@ async fn main() -> mongodb::error::Result<()> {
4847 let credential = Credential :: builder ( )
4948 . mechanism ( AuthMechanism :: MongoDbOidc )
5049 . mechanism_properties (
51- doc ! { "ENVIRONMENT" : "gcp" , "TOKEN_RESOURCE" : "<audience>" }
50+ doc ! { "ENVIRONMENT" : "gcp" , "TOKEN_RESOURCE" : "<audience>" }
5251 )
53- . build ( )
54- . into ( ) ;
52+ . build ( ) ;
5553
5654 client_options. credential = Some ( credential) ;
5755 let client = Client :: with_options ( client_options) ?;
@@ -87,23 +85,25 @@ async fn main() -> mongodb::error::Result<()> {
8785 // end-custom-callback-machine
8886
8987 // start-custom-callback-user
90- async fn cb ( params : CallbackContext ) -> mongodb:: error:: Result < IdpServerResponse > {
91- let idp_info = params. idp_info . ok_or ( Error :: NoIDPInfo ) ?;
92- let ( access_token, expires, refresh_token) = negotiate_with_idp ( ctx, idpInfo. Issuer ) . await ?;
93- Ok ( IdpServerResponse :: builder ( ) . access_token ( access_token) . expires ( expires) . refresh_token ( refresh_token) . build ( ) )
94- }
95- client_options. credential = Credential :: builder ( )
96- . mechanism ( AuthMechanism :: MongoDbOidc )
97- . oidc_callback ( oidc:: Callback :: human ( move |c| {
98- async move { cb ( c) . await } . boxed ( )
99- } ) )
100- . build ( )
101- . into ( ) ;
88+ let callback = Callback :: human ( move |context| {
89+ async move {
90+ "<human flow>"
91+ todo ! ( )
92+ }
93+ . boxed ( )
94+ } ) ;
95+ let credential = Credential :: builder ( )
96+ . mechanism ( AuthMechanism :: MongoDbOidc )
97+ . oidc_callback ( callback)
98+ . build ( ) ;
99+ client_options. credential = Some ( credential) ;
100+ let client = Client :: with_options ( client_options) ?;
101+
102102 let res = client
103103 . database ( "test" )
104104 . collection :: < Document > ( "test" )
105105 . find_one ( doc ! { } )
106- . await ;
106+ . await ? ;
107107 // end-custom-callback-user
108108
109109 Ok ( ( ) )
0 commit comments