Sign in with a ChatGPT subscription
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 20/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- api, authentication, backend, desktop
Línea de trabajo
Start with #38, which this work depends on, then read src/server/upstream/client.ts and src/server/upstream/proxy/handler.ts to understand request routing. The issue maps work across provider types and runtime, OAuth storage and API, desktop settings, CLI cleanup, and docs/glossary.md. Done means the ChatGPT sign-in flow, token refresh, model routing, safeguards, and cleanup work, with the listed tests and manual checks passing.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
DreamCoder only accepts API keys. Many people pay for ChatGPT but have no OpenAI API key, so they cannot use DreamCoder with that subscription.
#104 (ac0ea44) removed the earlier subscription sign-in ("DreamCoder is BYOK only"). This issue brings back ChatGPT only. Claude account sign-in stays removed, and Grok is out of scope.
What is in the tree today
- CLI side, still present but unreachable from the app:
src/services/openaiAuth/.client.ts:9-15holds the issuer (auth.openai.com), the Codex client id, the endpointchatgpt.com/backend-api/codex/responses, callback port 1455 and/auth/callback.- It also has the authorize, exchange and refresh code, and reads
chatgpt_account_idfrom the JWT. fetch.tsrewrites/v1/messagesinto a streaming Responses request.models.tshas a hard-coded model list.claude auth login --openaiis still registered.
- Reusable:
AuthCodeListener(src/services/oauth/auth-code-listener.ts), a temporary localhost server that checksstate, and the PKCE helpers (src/services/oauth/crypto.ts). - Removed in #104: the server OAuth service,
/api/provider-openai-oauth, the fixedopenai-officialprovider (runtimeKind: 'openai_oauth') and the desktop login component. They can be read withgit show ac0ea44^:<path>as a reference.
In the removed design the CLI process called ChatGPT itself and skipped the upstream module (docs/glossary.md:23-25, "官方渠道"). This issue proposes a different design.
Design
The server owns the tokens, and requests go through the upstream module.
Why not restore the old design:
- OpenAI rotates refresh tokens. With several CLI and scheduled-task processes refreshing from one token file, one refresh can invalidate the tokens the others hold.
- #83 made
src/server/upstream/client.tsthe only place that talks to upstreams. ChatGPT should not be the exception.
Upstream module (src/server/upstream/client.ts)
UpstreamTarget(:25-30) is a fixed{ baseUrl, apiKey, apiFormat, authStrategy }, and both OpenAI formats hard-codeAuthorization: Bearer ${apiKey}(:125,:133). Changes:- Auth resolved per request. Add an async auth step that returns fresh headers. The target is already rebuilt on every request (
proxy/handler.ts:23), so this is the natural place. - Full endpoint URL.
/v1/responsesis hard-coded and cannot produce/backend-api/codex/responses. - Extra headers:
ChatGPT-Account-Id, plus whatever client identification the backend requires. - Streaming only. The Codex backend needs
stream: true. Non-streaming callers (title generation, the provider test) must stream and aggregate. The aggregator exists:proxy/streaming/openaiResponsesStreamToAnthropicResponse.ts. - Reasoning summaries. When thinking is enabled, send
reasoning: { effort, summary: 'auto' }, as the Codex CLI does. Withoutsummarythe backend streams noreasoning_summary_textevents and no thinking shows. #38 leaves this out on purpose: OpenAI's public API rejectssummaryfor unverified organizations on some models, so it is added only for this provider. - One refresh and retry on 401.
- Auth resolved per request. Add an async auth step that returns fresh headers. The target is already rebuilt on every request (
Provider model
- Add an OAuth kind next to
anthropic_compatible(src/server/types/provider.ts:19). It has noapiKeyand usesapiFormat: openai_responses. - It always routes through
/proxy(providerRuntimeEnv.ts:185-190). The CLI sees the usual dummy key. checkAuthStatusandrunProviderTest(providerService.ts:305-308, which rejects an empty key) learn about it.- Models: follow #120. The candidates come from the account's model list on the Codex backend, with the current list in
models.tsas a fallback (it is already out of date). The user adds models and may pick a fast model, like any other provider. No role mapping of its own.
Server OAuth service and API
- Start sign-in: PKCE,
state, callback onlocalhost:1455/auth/callbackthroughAuthCodeListener. Also offer copy-link and paste-the-code fallbacks for when the browser cannot reach the callback. - Status and sign-out endpoints.
- Token storage (decided): a
0600file under<configDir>/dreamcoder/on every platform, written atomically. No keychain: once an unsigned app carries the quarantine attribute, the macOS keychain can silently refuse a headless process like the sidecar, so token reads would fail with 403. The file also gives one code path on all three platforms (Windows and Linux have no keychain support in the tree,src/utils/secureStorage/index.ts:9-17). API keys are already stored in plainproviders.json, so this is no weaker. - Tokens never leave the server.
GET /api/providersalready returns API keys to the UI (providerService.ts:101-104). OAuth tokens must not be added to it.
Desktop
- A "Sign in with ChatGPT" choice in Settings → Providers, showing the account and plan and offering sign-out.
- A risk confirmation before the first sign-in. This is not an official integration (see below). The user should know the account could be restricted.
Clean-up
- Remove the CLI-only path that nothing in the app reaches:
src/services/api/client.ts:185-208,claude auth login --openai,fetch.ts. Keep only what the server reuses. - Update
docs/glossary.md("官方渠道") to the new design.
Depends on
- #120 (any number of models per provider, optional fast model).
- #38 (Responses content shape, reasoning, cached tokens). Without it screenshots are dropped and reasoning never shows. One point there needs checking against the Codex backend: assistant text parts are sent as
input_text, and the backend may expectoutput_text.
Risks
- Not official. Sign-in uses the Codex CLI's public client id, and requests identify as the Codex client. OpenAI can block this or restrict accounts at any time.
- Unpublished backend. Headers, required fields and allowed models can change without notice. Our client identification (
codex-cli/0.91.0inclient.ts:15) is already far behind the current Codex CLI. - Port 1455 is fixed by the registered redirect. It collides with a running Codex CLI login.
- Windows:
AuthCodeListenerbindslocalhost(auth-code-listener.ts:46), which may resolve to::1. Tokens are stored as a plain file. Needs separate verification. - Local access to
/proxy: it requires a token only in some modes (src/server/index.ts:283-295). Any local process could then spend the user's subscription through it. Worth tightening as part of this work.
Plan
One PR, after #38:
- Upstream module: per-request auth, endpoint override, headers, streaming only, retry on 401.
- Provider kind and runtime env.
- Server OAuth service, API, token storage.
- Desktop sign-in, risk confirmation, model list.
- Remove the CLI-only path and update the glossary.
- Tests: a fake auth server for the full flow and refresh (including a rotated refresh token), the upstream request shape for Codex, and the aggregation for non-streaming callers.
Verification
- Unit and integration tests as above.
- Manual on macOS with a real ChatGPT account:
- sign in, chat with a screenshot, see the reasoning;
- a title is generated;
- a scheduled task runs;
- force an expired access token and confirm the refresh;
- sign out.
- Windows needs separate verification.
- Lenguaje dominante
- TypeScript
- Estrellas
- 490
- Forks
- 47
- Merge medio
- 9 h 38 min
- PR fusionados (30 d)
- 75
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de GoDiao/dreamcoder
-
Agent teams: in-process teammates never claim tasks from the team's task listPosiblemente ocupada @Sagar07Kr la tomó hace 5 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
GoDiao/dreamcoder#163 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[good first issue] UX polish — friendlier copy for error toasts and empty statesPosiblemente ocupada @iamcipherdev la tomó hace 12 días. Abiertoarea:i18n area:ux difficulty:1 good first issue mentor-available
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
GoDiao/dreamcoder#9 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Add more provider presets (Groq / OpenRouter / SiliconFlow / etc.)Quizá libre de nuevo @01iamysf la tomó hace 19 días y no hay ningún pull request abierto. Abiertoarea:desktop area:provider difficulty:1 good first issue mentor-available
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
GoDiao/dreamcoder#6 · 6 comentarios ·
Los mantenedores suelen responder en 1 día
-
area:desktop bug difficulty:2 good first issue help wanted
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
GoDiao/dreamcoder#195 ·
Los mantenedores suelen responder en 1 día
-
Move desktop UI components to shadcn/ui (Radix) and Pierre DiffsPosiblemente ocupada @GoDiao la tomó hace 2 días. Abiertoarea:desktop area:ux enhancement
GoDiao/dreamcoder#191 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de GoDiao/dreamcoder
Issues similares
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
b310-digital/teammapper#1515 ·
Los mantenedores suelen responder en 1 día
-
OneNote: import empty sectionsAbiertoonenote
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
obsidianmd/obsidian-importer#689 ·
-
In a half-screen window, the title bar cuts the workspace and version names until they can't be readAbiertobug launch local use macOS Windows
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[Integration]: eRPCAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
ava-labs/builders-hub#4826 ·
Los mantenedores suelen responder en 1 día
-
记忆分析的默认模型显示与实际使用不一致Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día