Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,6 @@ export const OpenAIAuthPlugin: Plugin = async ({ client }: PluginInput) => {
}
};

const storedAccountsForMethods = await loadAccounts();
const hasStoredAccounts = (storedAccountsForMethods?.accounts.length ?? 0) > 0;

const oauthMethod = {
label: AUTH_LABELS.OAUTH,
type: "oauth" as const,
Expand Down Expand Up @@ -865,9 +862,7 @@ export const OpenAIAuthPlugin: Plugin = async ({ client }: PluginInput) => {

const apiKeyMethod = { label: AUTH_LABELS.API_KEY, type: "api" as const };

const authMethods = hasStoredAccounts
? [oauthMethod]
: [oauthMethod, manualOauthMethod, apiKeyMethod];
const authMethods = [oauthMethod, manualOauthMethod, apiKeyMethod];

return {
auth: {
Expand Down
13 changes: 9 additions & 4 deletions test/auth-login-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,21 @@ describe("auth login workflow", () => {
expect(AUTH_LABELS.OAUTH_MANUAL).toBe("Codex Oauth (headless)");
});

it("exposes only oauth login when accounts exist", async () => {
it("retains oauth/manual/api login when accounts exist", async () => {
mockLoadAccounts.mockResolvedValueOnce(fixture);

const OpenAIAuthPlugin = await loadPlugin();
const plugin = await OpenAIAuthPlugin(createPluginInput());
const labels = plugin.auth?.methods.map((method) => method.label) ?? [];

expect(labels).toContain(AUTH_LABELS.OAUTH);
expect(labels).not.toContain(AUTH_LABELS.API_KEY);
expect(labels).toHaveLength(1);
expect(labels).toEqual(
expect.arrayContaining([
AUTH_LABELS.OAUTH,
AUTH_LABELS.OAUTH_MANUAL,
AUTH_LABELS.API_KEY,
]),
);
expect(labels).toHaveLength(3);
});

it("exposes oauth/manual/api login when no accounts exist", async () => {
Expand Down