From 24535c59224798a369ab0b564e5c896bb9db4859 Mon Sep 17 00:00:00 2001 From: Javier Soto Date: Tue, 4 Nov 2025 11:01:00 -0800 Subject: [PATCH] Implement proper fix: also set the token expiration time when it's expired MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old load path in codex-rs/rmcp-client/src/oauth.rs only set expires_in when the stored expiry was in the future: // codex-rs/rmcp-client/src/oauth.rs:369-374 (original) if let Some(expires_at) = entry.expires_at && let Some(seconds) = expires_in_from_timestamp(expires_at) { let duration = Duration::from_secs(seconds); token_response.set_expires_in(Some(&duration)); } And expires_in_from_timestamp returned None for expired tokens: // codex-rs/rmcp-client/src/oauth.rs:444-453 (original) if expires_at <= now_ms { None } else { Some((expires_at - now_ms) / 1000) } So when the stored token was already expired, set_expires_in was never called, RMCP saw “no expiry,” and it didn’t auto-refresh on handshake. --- codex-rs/rmcp-client/src/oauth.rs | 5 ++--- codex-rs/rmcp-client/src/rmcp_client.rs | 17 ----------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/codex-rs/rmcp-client/src/oauth.rs b/codex-rs/rmcp-client/src/oauth.rs index bd6833fca4..af01cdfa88 100644 --- a/codex-rs/rmcp-client/src/oauth.rs +++ b/codex-rs/rmcp-client/src/oauth.rs @@ -366,9 +366,8 @@ fn load_oauth_tokens_from_file(server_name: &str, url: &str) -> Result bool { - match token.expires_in() { - Some(duration) => duration.as_secs() <= REFRESH_SKEW_SECS, - None => token.refresh_token().is_some(), - } -}