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
@peterbecich

Copy link
Copy Markdown

Thanks for this.

Will this change the detail in the readme

ChatGPT subscription (requires paid subscription and doesn't work in remote projects)

?

@anvilpete anvilpete force-pushed the device-code-auth-elicitation branch from ea80074 to 93e8aef Compare June 10, 2026 16:28
@anvilpete

Copy link
Copy Markdown
Contributor Author

Thanks for this.

Will this change the detail in the readme

ChatGPT subscription (requires paid subscription and doesn't work in remote projects)

?

Yes, for clients that support URL-mode elicitations. And it doesn't require a paid subscription either. In any case, I've updated the README to remove that text.

@anvilpete anvilpete marked this pull request as ready for review June 10, 2026 19:20
@anvilpete

Copy link
Copy Markdown
Contributor Author

@benbrandt thanks for your help adding elicitation support to the SDK, that unblocks this PR.

I realise this project isn't a major focus at the moment, but this is a good example of ACP elicitation in action, has quite a few votes in #149, and would make my life a whole lot easier if it can be upstreamed!

Many thanks

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.

2 participants