Skip to content

feat: Sign in with ChatGPT#1892

Closed
neominik wants to merge 3 commits into
anomalyco:devfrom
neominik:feat/sign-in-with-chatgpt
Closed

feat: Sign in with ChatGPT#1892
neominik wants to merge 3 commits into
anomalyco:devfrom
neominik:feat/sign-in-with-chatgpt

Conversation

@neominik

Copy link
Copy Markdown
Contributor

Adds support for signing in with ChatGPT (same as in codex) through opencode auth login. Unfortunately, I cannot test if it actually works because support for enterprise accounts is "coming soon".

If anyone with a Plus, Pro, or Team ChatGPT account could test this via bun run dev -- auth login, that would be awesome.

@wizardlyluke

Copy link
Copy Markdown

I just tried this out with my Pro account and I get a missing organization_id error.

◒  Waiting for authorizationAPI key exchange failed: 401 Unauthorized {
  "error": {
    "message": "Invalid ID token: missing organization_id",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_subject_token"
  }

@neominik

Copy link
Copy Markdown
Contributor Author

Thanks for trying! I aligned the implementation more closely with what codex does. Not sure if it will fix your issue. If not, I'll convert to draft and park this until enterprise accounts are supported unless someone else want's to give it a shot.

@wizardlyluke

Copy link
Copy Markdown

Alright I seem to get a different error now. This login works with codex so I'm guessing something else is up. I was thinking it wasn't passing the organization ID but I couldn't get it to work when doing that either, or I'm just not doing it right.
■ Login incomplete — please finish your OpenAI organization/project setup in the browser

@hazyone

hazyone commented Sep 2, 2025

Copy link
Copy Markdown

Is it work now? :)

@mpazik mpazik mentioned this pull request Sep 21, 2025
@mpazik

mpazik commented Sep 22, 2025

Copy link
Copy Markdown

This code did not work for me. I tried to use the OpenAI OAuth token directly from Codex CLI in OpenCode; however, for the OAuth token to be used, I belive the request would need to go through a opencode's plugin.

It seems like making a plugin similar to the one for Anthropic would be a correct way of implementing OAuth for OpenAI.
https://github.com/sst/opencode-anthropic-auth/tree/master

Another issue I came across was that the OAuth token from Codex CLI worked only on the Codex base URL "https://chatgpt.com/backend-api/codex" that accepts only Codex system prompts.

@neominik

Copy link
Copy Markdown
Contributor Author

Thanks @mpazik for looking into this. I currently don't have the capacity to make such large changes, so I'll close this PR for now. If anyone else wants to give it a shot, feel free to reuse anything here.

@neominik neominik closed this Sep 22, 2025
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.

4 participants