Propagate auth session logging ID in ChatGPT login

This commit is contained in:
Darren Hwang
2026-06-04 06:42:46 +00:00
parent 80b65e9945
commit 2fac8460a7
17 changed files with 166 additions and 7 deletions
+1
View File
@@ -84,6 +84,7 @@ tracing-appender = { workspace = true }
tracing-subscriber = { workspace = true }
unicode-segmentation = { workspace = true }
url = { workspace = true }
uuid = { workspace = true, features = ["v4"] }
which = { workspace = true }
[target.'cfg(target_os = "windows")'.dependencies]
+11 -1
View File
@@ -30,6 +30,7 @@ use tracing_subscriber::EnvFilter;
use tracing_subscriber::Layer;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use uuid::Uuid;
const CHATGPT_LOGIN_DISABLED_MESSAGE: &str =
"ChatGPT login is disabled. Use API key login instead.";
@@ -118,12 +119,15 @@ pub async fn login_with_chatgpt(
forced_chatgpt_workspace_id: Option<Vec<String>>,
cli_auth_credentials_store_mode: AuthCredentialsStoreMode,
) -> std::io::Result<()> {
let opts = ServerOptions::new(
let auth_session_logging_id = Uuid::new_v4().to_string();
tracing::info!(auth_session_logging_id = %auth_session_logging_id, "starting browser login attempt");
let mut opts = ServerOptions::new(
codex_home,
CLIENT_ID.to_string(),
forced_chatgpt_workspace_id,
cli_auth_credentials_store_mode,
);
opts.auth_session_logging_id = Some(auth_session_logging_id);
let server = run_login_server(opts)?;
print_login_server_start(server.actual_port, &server.auth_url);
@@ -335,6 +339,12 @@ pub async fn run_login_with_device_code_fallback_to_browser(
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound {
eprintln!("Device code login is not enabled; falling back to browser login.");
let auth_session_logging_id = Uuid::new_v4().to_string();
tracing::info!(
auth_session_logging_id = %auth_session_logging_id,
"starting browser login fallback attempt"
);
opts.auth_session_logging_id = Some(auth_session_logging_id);
match run_login_server(opts) {
Ok(server) => {
print_login_server_start(server.actual_port, &server.auth_url);