Skip to content

Device code auth support#291

Open
anvilpete wants to merge 1 commit into
zed-industries:mainfrom
anvilpete:device-code-auth-elicitation
Open

Device code auth support#291
anvilpete wants to merge 1 commit into
zed-industries:mainfrom
anvilpete:device-code-auth-elicitation

Conversation

@anvilpete
Copy link
Copy Markdown
Contributor

This PR adds device code auth support for ChatGPT login when no browser is available.

It's an alternative implementation to #281. Instead of using a custom error data, the agent sends a URL-mode elicitation to initiate a device code auth flow:

-> AuthenticateRequest
<- CreateElicitationRequest (url mode, request scope)
-> CreateElicitationResponse (accept)
<- AuthenticateResponse

An elicitation/complete isn't required, due to the AuthenticateResponse sent when authentication is complete (or an error if it failed).

The Rust SDK doesn't currently include elicitation schema in its unstable feature. I've added this in agentclientprotocol/rust-sdk#163, which this PR depends on.

Comment thread src/codex_agent.rs
responder.respond_with_result(agent.authenticate(request).await)
responder.respond_with_result(
agent.authenticate(request, auth_cx, request_id).await,
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

cx is passed in here to allow the handler to spawn a complete_device_code_login() task. We could perhaps pass a narrower spawner trait instead, or maybe even return a Future from the handler.

Comment thread README.md
- Custom Prompts
- Client MCP servers
- Auth Methods:
- ChatGPT subscription (requires paid subscription and doesn't work in remote projects)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Paid subscriptions aren't required.. maybe they were at some point in the past?

Comment thread src/codex_agent.rs
let agent = agent.clone();
let auth_cx = cx.clone();
let request_id = request_id_from_json(responder.id())
.expect("request id must be a string or number");
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This could be avoided if responder exposed a Responder::request_id() -> RequestId or similar.

@anvilpete
Copy link
Copy Markdown
Contributor Author

This PR adds support for #149.

CI failures are due to the dependency on agentclientprotocol/rust-sdk#163.

@anvilpete anvilpete force-pushed the device-code-auth-elicitation branch from faac66f to 9594756 Compare May 15, 2026 13:16
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