Skip to content

feat(auth): add ChatGPT Plus/Pro OAuth provider - #1529

Open
qipenglin wants to merge 1 commit into
MoonshotAI:mainfrom
qipenglin:codex/chatgpt-oauth-provider
Open

feat(auth): add ChatGPT Plus/Pro OAuth provider#1529
qipenglin wants to merge 1 commit into
MoonshotAI:mainfrom
qipenglin:codex/chatgpt-oauth-provider

Conversation

@qipenglin

Copy link
Copy Markdown

Related Issue

Resolves #1523

Problem

See linked issue.

What changed

  • Add OpenAI device-code OAuth login for ChatGPT Plus/Pro subscriptions, including credential storage and token refresh.
  • Fetch the account's available Codex model catalog after login, with a conservative built-in fallback when catalog discovery is unavailable.
  • Configure the ChatGPT Codex request path with the required account headers and omit unsupported completion-budget parameters.
  • Add focused OAuth and runtime-provider coverage, bilingual provider documentation, and a CLI changeset.

This integration uses the ChatGPT Codex backend rather than OpenAI API-key billing. Model visibility and metadata come from the authenticated account when available.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c61ffef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@qipenglin
qipenglin force-pushed the codex/chatgpt-oauth-provider branch from 789a5a3 to 4d824e7 Compare July 10, 2026 08:05
@qipenglin
qipenglin marked this pull request as ready for review July 21, 2026 00:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d824e7a3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +136 to +140
supportEfforts,
defaultEffort: model.defaultEffort ?? (supportEfforts.includes('medium') ? 'medium' : supportEfforts[0]),
};
}
const selection = await runModelSelector(host, modelDict);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Initialize the selector with a supported thinking effort

When a user completes ChatGPT login and accepts the initially selected model without changing the thinking control, every alias here has concrete supportEfforts. runModelSelector initializes that first alias with 'on', but ModelSelectorComponent treats 'on' as invalid for an effort-backed model and clamps it to the first segment, 'off'; consequently selection.thinking !== 'off' persists thinking.enabled = false. The default login path therefore silently disables reasoning instead of using the model's declared default effort.

Useful? React with 👍 / 👎.

Comment on lines +141 to +146
if (this.isOpenAICodexAuth(providerName, oauthRef)) {
return createOpenAICodexTokenProvider({
storage: new FileTokenStorage(join(this.options.homeDir, 'credentials')),
providerName,
oauthRef,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Map revoked ChatGPT tokens to login-required errors

When a stored ChatGPT refresh token is revoked or expires, createOpenAICodexTokenProvider throws OAuthUnauthorizedError directly here. The SDK facade added in the same commit wraps this provider with mapOAuthTokenError, but the service-backed runtime uses this facade through CoreProcessService; it will therefore emit an unclassified/internal error rather than auth.login_required, so clients such as the TUI do not show the /login remediation for an expired ChatGPT session.

Useful? React with 👍 / 👎.

@qipenglin
qipenglin force-pushed the codex/chatgpt-oauth-provider branch 7 times, most recently from 220c8d2 to d529b50 Compare July 23, 2026 09:40
@qipenglin
qipenglin force-pushed the codex/chatgpt-oauth-provider branch from d529b50 to c61ffef Compare July 23, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support ChatGPT Plus/Pro OAuth as a login provider

1 participant