Skip to content

Commit

Permalink
Switch to println! instead of tracing for now
Browse files Browse the repository at this point in the history
  • Loading branch information
jshearer committed Dec 4, 2023
1 parent 38556c5 commit 8b38ca6
Showing 1 changed file with 9 additions and 32 deletions.
41 changes: 9 additions & 32 deletions crates/flowctl/src/raw/oauth.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use crate::local_specs;
use anyhow::{bail, Context};
use itertools::Itertools;
use proto_flow::{capture, flow};
use std::{
collections::HashMap,
fmt::{Debug, Display},
net::ToSocketAddrs,
fmt::Debug,
sync::{Arc, Mutex},
time::Duration,
};
use tokio::time::timeout_at;
use warp::{http::Response, Filter};

#[derive(Debug, clap::Args)]
Expand Down Expand Up @@ -57,21 +54,6 @@ pub async fn do_oauth(
injected_values,
}: &Oauth,
) -> anyhow::Result<()> {
// TESTING
let env_filter = tracing_subscriber::EnvFilter::builder()
.with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into()) // Otherwise it's ERROR.
.from_env_lossy();

let guard = tracing::subscriber::set_default(
tracing_subscriber::fmt::fmt()
.with_env_filter(env_filter)
.compact()
.without_time()
.with_target(false)
.with_writer(std::io::stderr)
.finish(),
);
// END TESTING
let source = build::arg_source_to_url(source, false)?;
let mut sources = local_specs::surface_errors(local_specs::load(&source).await.into_result())?;

Expand All @@ -95,9 +77,9 @@ pub async fn do_oauth(
Err(_) => anyhow::bail!("could not find the capture {needle}"),
};

tracing::info!(
task_name = capture.capture.as_str(),
"Performing oauth flow on task"
println!(
"Performing oauth flow on task '{}'",
capture.capture.as_str()
);

let spec_req = match &capture.spec.endpoint {
Expand Down Expand Up @@ -186,7 +168,7 @@ pub async fn do_oauth(
)?.ok()
.context("Provided endpoint config did not match schema.")?;

tracing::info!(
println!(
"Got connector's OAuth spec: {}",
serde_json::to_string_pretty(&oauth_spec)?
);
Expand Down Expand Up @@ -235,16 +217,13 @@ pub async fn do_oauth(
format!("Unexpected auth-url response body: {str}")
})?;

tracing::info!(url = authorize_response.url, "Opening authorize URL");
println!("Opening authorize URL {}", authorize_response.url);

open::that(authorize_response.url)?;

let redirect_params = get_single_request_query(([127, 0, 0, 1], port)).await?;

tracing::info!(
redirect_params = ?redirect_params,
"Got auth code response parameters"
);
println!("Got auth code response parameters: {:?}", redirect_params);

let mut code_request_body = serde_json::json!({
"operation": "access-token",
Expand All @@ -265,7 +244,7 @@ pub async fn do_oauth(
code_request_map.insert(k, serde_json::Value::String(v));
}

tracing::info!("Exchanging auth code for access token");
println!("Exchanging auth code for access token");

let code_response = reqwest::Client::new()
.post(oauth_endpoint)
Expand All @@ -277,13 +256,11 @@ pub async fn do_oauth(
.json::<serde_json::Value>()
.await?;

tracing::info!(
println!(
"🎉 Got access token response: \n{}",
serde_json::to_string_pretty(&code_response)?
);

drop(guard);

Ok(())
}

Expand Down

0 comments on commit 8b38ca6

Please sign in to comment.