feat: remove RefreshToken command from CLI and associated logic

This commit is contained in:
2026-04-30 14:15:46 +08:00
Unverified
parent 2442bff12a
commit ed1deae555
3 changed files with 0 additions and 17 deletions
-2
View File
@@ -45,8 +45,6 @@ pub enum Commands {
#[arg(long)]
json: bool,
},
/// Refresh OAuth tokens for a saved account.
RefreshToken { account: String },
/// Account management commands.
Account {
#[command(subcommand)]
-1
View File
@@ -79,7 +79,6 @@ async fn main() -> Result<()> {
.await
}
Commands::Quota { accounts, json } => quota::quota_command(accounts, json).await,
Commands::RefreshToken { account } => token::refresh_token_command(&account).await,
Commands::Account { command } => match command {
AccountCommands::List { json, force } => account::list_accounts(json, force).await,
AccountCommands::Current { json } => account::current_account(json),
-14
View File
@@ -14,20 +14,6 @@ const CLIENT_ID: &str = "app_EMoamEEZ73f0CkXaXp7hrann";
const TOKEN_ENDPOINT: &str = "https://auth.openai.com/oauth/token";
const TOKEN_REFRESH_SKEW_SECONDS: i64 = 300;
pub async fn refresh_token_command(query: &str) -> Result<()> {
let home = crate::paths::codex_home(None)?;
let mut store = Store::load(&home)?;
let account_id = store
.find_account(query)
.ok_or_else(|| anyhow!("账号不存在: {query}"))?
.id
.clone();
refresh_account(&mut store, &account_id).await?;
store.save(&home)?;
println!("已刷新账号 token: {account_id}");
Ok(())
}
pub async fn refresh_account_if_needed(store: &mut Store, account_id: &str) -> Result<bool> {
// Refresh shortly before expiry to avoid writing an auth.json that Codex
// immediately rejects.