@@ -30,10 +30,9 @@ async fn main() -> mongodb::error::Result<()> {
30
30
. username ( "<username>" . to_owned ( ) )
31
31
. mechanism ( AuthMechanism :: MongoDbOidc )
32
32
. mechanism_properties (
33
- doc ! { "ENVIRONMENT" : "azure" , "TOKEN_RESOURCE" : "<audience>" }
33
+ doc ! { "ENVIRONMENT" : "azure" , "TOKEN_RESOURCE" : "<audience>" }
34
34
)
35
- . build ( )
36
- . into ( ) ;
35
+ . build ( ) ;
37
36
38
37
client_options. credential = Some ( credential) ;
39
38
let client = Client :: with_options ( client_options) ?;
@@ -48,10 +47,9 @@ async fn main() -> mongodb::error::Result<()> {
48
47
let credential = Credential :: builder ( )
49
48
. mechanism ( AuthMechanism :: MongoDbOidc )
50
49
. mechanism_properties (
51
- doc ! { "ENVIRONMENT" : "gcp" , "TOKEN_RESOURCE" : "<audience>" }
50
+ doc ! { "ENVIRONMENT" : "gcp" , "TOKEN_RESOURCE" : "<audience>" }
52
51
)
53
- . build ( )
54
- . into ( ) ;
52
+ . build ( ) ;
55
53
56
54
client_options. credential = Some ( credential) ;
57
55
let client = Client :: with_options ( client_options) ?;
@@ -87,23 +85,25 @@ async fn main() -> mongodb::error::Result<()> {
87
85
// end-custom-callback-machine
88
86
89
87
// 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
+
102
102
let res = client
103
103
. database ( "test" )
104
104
. collection :: < Document > ( "test" )
105
105
. find_one ( doc ! { } )
106
- . await ;
106
+ . await ? ;
107
107
// end-custom-callback-user
108
108
109
109
Ok ( ( ) )
0 commit comments