-
Notifications
You must be signed in to change notification settings - Fork 3.3k
OAuth provider configuration not fully deleted - cache file persists #7890
Description
Summary
When deleting an OAuth provider configuration (specifically ChatGPT Codex), the provider is still shown a "configured" after deletion because cached OAuth tokens in disk files are not cleaned up. This causes the OAuth flow to complete instantly without opening a browser, making it appear as if the configuration was never deleted.
Steps to Reproduce
- Configure ChatGPT Codex provider (OAuth flow opens browser, you authorize)
- Delete the ChatGPT Codex configuration in the UI
- Click "Configure" on ChatGPT Codex again
- OAuth completes instantly without opening a browser
Expected Behavior
After deleting an OAuth provider configuration, re-configuring should:
- Open a browser for the OAuth flow
- Require fresh authorization
Actual Behavior
OAuth completes instantly because the cached token file persists at ~/.config/goose/chatgpt_codex/tokens.json.
Root Cause
The current deletion flow in ProviderConfigurationModal.tsx only removes:
- Configuration keys (via
remove()from ConfigContext) - The configured marker (
{provider}_configured)
But it does not clean up provider-specific cache files:
- ChatGPT Codex:
~/.config/goose/chatgpt_codex/tokens.json(disk cache) - Other OAuth providers: May have similar caches
Existing Code Patterns
ChatGPT Codex already has a TokenCache::clear() method (crates/goose/src/providers/chatgpt_codex.rs:261-263):
fn clear(&self) {
let _ = std::fs::remove_file(&self.cache_path);
}Custom providers also handle cleanup comprehensively in remove_custom_provider():
pub fn remove_custom_provider(id: &str) -> Result<()> {
let config = Config::global();
let api_key_name = generate_api_key_name(id);
let _ = config.delete_secret(&api_key_name);
let file_path = custom_providers_dir().join(format!("{}.json", id));
if file_path.exists() {
std::fs::remove_file(file_path)?;
}
Ok(())
}Proposed Solution
Add provider cleanup capability:
- Add
cleanup()method to Provider trait (crates/goose/src/providers/base.rs) - Implement in ChatGptCodexProvider to clear token cache
- Add backend endpoint
POST /config/providers/{name}/cleanup - Update frontend to call cleanup endpoint before closing delete modal
- Update CLI to call cleanup when removing provider config
Affected Providers
- ChatGPT Codex - Uses disk cache file
- GitHub Copilot - Uses keyring (already handles via configured marker)