Skip to content

fix: accept RT-exchanged tokens missing chatgpt_account_id claim#2

Closed
xiaoliu10 wants to merge 4 commits into
devfrom
fix/rt-import-missing-account-id
Closed

fix: accept RT-exchanged tokens missing chatgpt_account_id claim#2
xiaoliu10 wants to merge 4 commits into
devfrom
fix/rt-import-missing-account-id

Conversation

@xiaoliu10

Copy link
Copy Markdown
Owner

What

Importing an account via refresh token fails when OpenAI's RT exchange returns an access_token that omits the chatgpt_account_id claim — the strict validateToken path rejects it.

Changes

  • jwt-utils.ts: add extractCodexTokenMetadata() to pull accountId / userId / email / planType from access_token, falling back to id_token.
  • account-import.ts: RT-exchange path now bypasses validateToken and uses a dedicated validateRtExchangeToken() that only checks the token is decodable and not expired — no more fragile error-string matching.
  • account-pool.ts / account-registry.ts / oauth-pkce.ts: thread imported metadata through; refresh now returns id_token.
  • Tests cover RT import succeeding without an account id.

Note

Supersedes closed PR #1 (its head commit was rewritten by an amend, so GitHub could not reopen it).

🤖 Generated with Claude Code

jason and others added 4 commits June 10, 2026 16:01
…g match

Replace the fragile canAcceptRtExchangeToken() check (which matched on the
exact "Token missing chatgpt_account_id claim" error string) with a dedicated
validateRtExchangeToken() that only verifies the token is decodable and not
expired. RT-exchanged tokens legitimately omit chatgpt_account_id, so the
strict validateToken path should not gate them at all.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@xiaoliu10

Copy link
Copy Markdown
Owner Author

Created in error — this work is tracked upstream in icebear0828#674.

@xiaoliu10 xiaoliu10 closed this Jun 18, 2026
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.

1 participant