Skip to content

Commit 57fe648

Browse files
marijnvdwerfclaude
andcommitted
Support removing ChatGPT OAuth credentials
The DELETE /api/providers/openai-chatgpt endpoint now removes the OAuth JSON credentials file instead of trying to look up a TOML key. Re-enable the Remove button in the UI for the ChatGPT Plus card. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5439a82 commit 57fe648

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

interface/src/routes/Settings.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,10 @@ export function Settings() {
601601
configured={isConfigured("openai-chatgpt")}
602602
defaultModel={CHATGPT_OAUTH_DEFAULT_MODEL}
603603
onEdit={() => setOpenAiOAuthDialogOpen(true)}
604-
onRemove={() => {}}
605-
removing={false}
604+
onRemove={() => removeMutation.mutate("openai-chatgpt")}
605+
removing={removeMutation.isPending}
606606
actionLabel="Sign in"
607-
showRemove={false}
607+
showRemove={isConfigured("openai-chatgpt")}
608608
/>
609609
) : null,
610610
]

src/api/providers.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,22 @@ pub(super) async fn delete_provider(
958958
State(state): State<Arc<ApiState>>,
959959
axum::extract::Path(provider): axum::extract::Path<String>,
960960
) -> Result<Json<ProviderUpdateResponse>, StatusCode> {
961+
// OpenAI ChatGPT OAuth credentials are stored as a separate JSON file,
962+
// not in the TOML config, so handle removal separately.
963+
if provider == "openai-chatgpt" {
964+
let instance_dir = (**state.instance_dir.load()).clone();
965+
let cred_path = crate::openai_auth::credentials_path(&instance_dir);
966+
if cred_path.exists() {
967+
tokio::fs::remove_file(&cred_path)
968+
.await
969+
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
970+
}
971+
return Ok(Json(ProviderUpdateResponse {
972+
success: true,
973+
message: "ChatGPT Plus OAuth credentials removed".into(),
974+
}));
975+
}
976+
961977
let Some(key_name) = provider_toml_key(&provider) else {
962978
return Ok(Json(ProviderUpdateResponse {
963979
success: false,

0 commit comments

Comments
 (0)