github / github/copilot-cli

Copilot CLI OAuth login fails — CLI doesn't bind to port declared in its own CIMD client-metadata.json

未关闭
#4,800 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

triage
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

Describe the bug

When authenticating to an MCP server that uses CIMD (Client ID Metadata Document) OAuth, Copilot CLI fails with:

{"error":"invalid_request","error_description":"Redirect URI 'http://127.0.0.1:<random_port>/' does not match CIMD redirect_uris.","state":"..."}

Root cause: Copilot CLI's own published client metadata ( https://github.com/copilot/cli/client-metadata.json ) declares a single fixed redirect URI:

"redirect_uris": ["http://127.0.0.1:33418/"]

Per the CIMD/OAuth spec, the redirect_uri used in the  /authorize  request must exactly match this declared value (RFC 8252's "any loopback port" leniency only applies when no port is specified — here one is).

However, Copilot CLI does not bind its local OAuth callback listener to port 33418 — it uses a different, seemingly random port instead (observed: 63450, then 61566), even when port 33418 is confirmed free/unused on the machine. This causes every login attempt against CIMD-based OAuth servers to fail.

Affected version

Copilot CLI v1.0.83, Windows

Steps to reproduce the behavior
  1. Confirm port 33418 is free ( Get-NetTCPConnection -LocalPort 33418  returns nothing).
  2. Attempt login to an MCP server using CIMD OAuth (client_id = a metadata document URL).
  3. Copilot CLI opens a callback listener on a different port than 33418.
  4. Server rejects with  invalid_request  / redirect_uri mismatch.
Expected behavior

Copilot CLI should bind its OAuth loopback listener to the exact port(s) declared in its own  client-metadata.json  (33418), consistent with CIMD requirements.

Additional context

No response

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先跟踪从 /authorize 请求到本地 loopback 回调监听器的 OAuth 流程,然后将其选择的端口与已发布的 client-metadata.json 中的 redirect_uris 值进行比较。在端口 33418 空闲且使用 CIMD MCP 服务器的情况下复现;完成标准是监听器和请求使用所声明的 URI,并且登录不再返回 invalid_request。

由索引模型根据 Issue 内容生成。

评估

技术栈
shell
领域
authentication, cli
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
描述清楚
新手友好度
64/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。