11use crate :: local_specs;
22use anyhow:: { bail, Context } ;
3- use itertools:: Itertools ;
43use proto_flow:: { capture, flow} ;
54use std:: {
65 collections:: HashMap ,
7- fmt:: { Debug , Display } ,
8- net:: ToSocketAddrs ,
6+ fmt:: Debug ,
97 sync:: { Arc , Mutex } ,
108 time:: Duration ,
119} ;
12- use tokio:: time:: timeout_at;
1310use warp:: { http:: Response , Filter } ;
1411
1512#[ derive( Debug , clap:: Args ) ]
@@ -57,21 +54,6 @@ pub async fn do_oauth(
5754 injected_values,
5855 } : & Oauth ,
5956) -> anyhow:: Result < ( ) > {
60- // TESTING
61- let env_filter = tracing_subscriber:: EnvFilter :: builder ( )
62- . with_default_directive ( tracing_subscriber:: filter:: LevelFilter :: INFO . into ( ) ) // Otherwise it's ERROR.
63- . from_env_lossy ( ) ;
64-
65- let guard = tracing:: subscriber:: set_default (
66- tracing_subscriber:: fmt:: fmt ( )
67- . with_env_filter ( env_filter)
68- . compact ( )
69- . without_time ( )
70- . with_target ( false )
71- . with_writer ( std:: io:: stderr)
72- . finish ( ) ,
73- ) ;
74- // END TESTING
7557 let source = build:: arg_source_to_url ( source, false ) ?;
7658 let mut sources = local_specs:: surface_errors ( local_specs:: load ( & source) . await . into_result ( ) ) ?;
7759
@@ -95,9 +77,9 @@ pub async fn do_oauth(
9577 Err ( _) => anyhow:: bail!( "could not find the capture {needle}" ) ,
9678 } ;
9779
98- tracing :: info !(
99- task_name = capture . capture . as_str ( ) ,
100- "Performing oauth flow on task"
80+ println ! (
81+ "Performing oauth flow on task '{}'" ,
82+ capture . capture . as_str ( )
10183 ) ;
10284
10385 let spec_req = match & capture. spec . endpoint {
@@ -186,7 +168,7 @@ pub async fn do_oauth(
186168 ) ?. ok ( )
187169 . context ( "Provided endpoint config did not match schema." ) ?;
188170
189- tracing :: info !(
171+ println ! (
190172 "Got connector's OAuth spec: {}" ,
191173 serde_json:: to_string_pretty( & oauth_spec) ?
192174 ) ;
@@ -235,16 +217,13 @@ pub async fn do_oauth(
235217 format ! ( "Unexpected auth-url response body: {str}" )
236218 } ) ?;
237219
238- tracing :: info! ( url = authorize_response . url , "Opening authorize URL" ) ;
220+ println ! ( "Opening authorize URL {}" , authorize_response . url ) ;
239221
240222 open:: that ( authorize_response. url ) ?;
241223
242224 let redirect_params = get_single_request_query ( ( [ 127 , 0 , 0 , 1 ] , port) ) . await ?;
243225
244- tracing:: info!(
245- redirect_params = ?redirect_params,
246- "Got auth code response parameters"
247- ) ;
226+ println ! ( "Got auth code response parameters: {:?}" , redirect_params) ;
248227
249228 let mut code_request_body = serde_json:: json!( {
250229 "operation" : "access-token" ,
@@ -265,7 +244,7 @@ pub async fn do_oauth(
265244 code_request_map. insert ( k, serde_json:: Value :: String ( v) ) ;
266245 }
267246
268- tracing :: info !( "Exchanging auth code for access token" ) ;
247+ println ! ( "Exchanging auth code for access token" ) ;
269248
270249 let code_response = reqwest:: Client :: new ( )
271250 . post ( oauth_endpoint)
@@ -277,13 +256,11 @@ pub async fn do_oauth(
277256 . json :: < serde_json:: Value > ( )
278257 . await ?;
279258
280- tracing :: info !(
259+ println ! (
281260 "🎉 Got access token response: \n {}" ,
282261 serde_json:: to_string_pretty( & code_response) ?
283262 ) ;
284263
285- drop ( guard) ;
286-
287264 Ok ( ( ) )
288265}
289266
0 commit comments