Repository navigation
Sign in and accounts
English | 简体中文
This page explains how you connect a ChatGPT account, what each step of sign-in does, where the account is stored, and how to disconnect it.
This section gives the two ways to start a sign-in and what you should see when it succeeds.
From the card. Open the plugin's card in the DSH web client. The ChatGPT account panel shows Not connected; press Sign in with ChatGPT. A browser tab opens on OpenAI's consent page. Approve the app and approve plan usage. The tab stays open until the plugin has validated the result, then shows the outcome. The panel switches to Connected and Plan access ready.
From a terminal. Run the command-line tool from a directory where the package is installed (for a DSH install, the profile directory):
npx dsh-chatgpt-siwc loginIt prints the authorization URL, opens it in your browser, waits for the callback, and then prints a token-free account summary followed by plan usage: granted — this account can serve model calls. Add --no-browser to only print the URL. See CLI and doctor for the other flags.
The browser has to run on the same machine as DSH: the callback goes to http://127.0.0.1:<port>/auth/callback.
This section explains the one rule that decides whether model calls are allowed after you sign in.
Sign-in proves who you are. Model calls need something more: the granted scopes must include chatgpt.tokens.use.direct. The plugin requests identity scopes (openid profile email) and plan scopes (offline_access resource.invoke chatgpt.tokens.use.direct) together. If the consent screen was approved without plan usage, the account is signed in but every model call is refused locally with an AUTH error, before anything is sent. The card then shows Plan access not available and the CLI prints plan usage: NOT granted — identity only. Sign in again and approve plan usage.
Plan limits are OpenAI's, not the plugin's. OpenAI documents plan usage in apps for eligible ChatGPT Go, Plus, Pro, and Business subscribers; on Business, a workspace admin has to allow plan usage for the app. App usage counts toward your existing plan limits. You can cap this app at a weekly percentage of your plan under Settings > Usage in ChatGPT (https://chatgpt.com/settings/usage, linked from the card as Manage usage). Source: OpenAI, Sign in with ChatGPT.
This section walks through the flow step by step, so a failure message can be matched to the step that produced it.
The card names the step a failed attempt stopped at; the stage names below are the ones it shows.
| Step | Card stage | What the plugin does |
|---|---|---|
| 1 | starting the local listener | Reads OpenAI's discovery document (https://auth.openai.com/.well-known/openid-configuration), falling back to the documented endpoints if it cannot. Opens a loopback listener on 127.0.0.1, preferring port 1455 and taking any free port if that one is busy. |
| 2 | waiting for ChatGPT approval | Opens the authorization URL with PKCE (S256), a fresh state and nonce, resource=https://api.openai.com/v1, and this installation's stable ext_agent_host_id. A first sign-in uses client_id=dynamic_agent_client plus agent_name_hint (default DSH SIWC), the app name shown on the consent page. |
| 3 | receiving the approval | Accepts the callback only if its state matches this attempt. The callback must arrive within 120 seconds. |
| 4 | app registered | On a first sign-in, saves the issued oaiapp_… client id before exchanging the code, so a retry after a later failure reconnects the same app instead of registering another one on your ChatGPT account. |
| 5 | exchanging the approval for access | Exchanges the one-time code at the token endpoint with the PKCE verifier and resource. There is no client secret. |
| 6 | verifying your identity | Verifies the ID token: RS256 signature against OpenAI's JWKS, issuer https://auth.openai.com, audience and azp equal to the issued client id, expiry, and the attempt's nonce. |
| 7 | saving the account | Writes the account under the cross-process lock and makes it active if no other signed-in account is active. |
Reconnecting an existing account reuses its client id. The reauthorization URL can carry the stored ID token as id_token_hint; the plugin removes it from the URL it prints and hands to the browser, so that credential never appears in a process list.
This section describes how the access token stays valid without you signing in again.
Access tokens are refreshed when they are within five minutes of expiry. A refresh runs under the accounts-file lock and re-reads the record first, so if another DSH or CLI process already rotated the token, it uses that result instead of spending the refresh token a second time. It respects the issuer's earliest_refresh_at and re-verifies any new ID token against the same account.
If OpenAI refuses the refresh token, the plugin clears the stored tokens, keeps the app registration, and asks you to sign in again (REAUTH_REQUIRED). If the Responses API answers 401 to a token that looked fresh, the plugin forces one refresh and retries the request once.
This section tells you which files hold your credentials and how they are protected.
| File | Contents | Protection |
|---|---|---|
$DSH_HOME/chatgpt-siwc/accounts.json (default ~/.dsh/chatgpt-siwc/accounts.json) |
Registrations, tokens, granted scopes, the cached model catalog, local usage totals, and the last observed usage window | File mode 0600, directory 0700. Outside Windows the plugin refuses to read the file if any group or other permission bit is set, and tells you to chmod 600 it. |
$DSH_HOME/chatgpt-siwc/host.json |
The stable ext_agent_host_id for this installation. No secrets. |
Written atomically under the same lock |
accounts.json.lock |
Present only while a writer holds the lock | Created and removed by the writer |
All writes are atomic. storePath in Configuration moves the accounts file; the CLI accepts --store <path> on every command. Tokens stay on your machine; nothing in the plugin sends them anywhere except OpenAI's token endpoints and the API origin described in Route and compliance.
This section covers what happens when one installation holds several registrations.
Each registration is keyed by its issued client id, and one of them is active. A second sign-in becomes active only when no signed-in account is active, so a failed second attempt never displaces the first. dsh-chatgpt-siwc login --new registers a separate app instead of reconnecting the active one. A client id is only ever sent with its own account's tokens.
This section explains what disconnecting does locally and at OpenAI.
- Card, Disconnect. Asks for confirmation, then revokes the refresh token at the revocation endpoint named by OpenAI's discovery document and clears the local tokens. The registration stays, so the next sign-in reconnects the same app.
-
CLI,
logout. Does the same. With--purgeit also deletes the account record fromaccounts.json.
Revocation is tried up to three times. If it cannot be confirmed, the CLI says it signed out locally only. You can always disconnect the app from the ChatGPT side under Settings > Security and login > Sign in with ChatGPT.
dsh-chatgpt-siwc
English
- Home
- Install
- Sign-in and accounts
- Configuration
- Models and catalog
- Prompt cache
- Route and compliance
- Architecture
- CLI and doctor
- Troubleshooting
- FAQ
- Changelog
- Contributing
简体中文