github / github/copilot-cli

Blocked as auth fails whenever -p or --agent used (enterprise login)

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

还没有人认领这个 Issue。

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

描述

Describe the bug

copilot fails to load due to auth issues when using -p --agent:

copilot -p "hello"

...worked fine.

Then if you run this, with --agent, it breaks:

copilot -p "hello" --agent my-agent

! Third-party MCP servers are disabled by your organization's Copilot policy. Only built-in servers are available.

Error: Authentication failed (Request ID: 2915:A0B85:4D563A2:5BD65FE:6A915A71)

Your GitHub token may be invalid, expired, or lacking the required permissions.

To resolve this, try the following:
  • Start 'copilot' and run the '/login' command to re-authenticate
  • If using a Fine-Grained PAT, ensure it has the 'Copilot Requests' permission enabled
  • If using COPILOT_GITHUB_TOKEN, GH_TOKEN or GITHUB_TOKEN environment variable, verify the token is valid and not expired
  • Run 'gh auth status' to check your current authentication status

And further more, once you do the above, then:

copilot -p "hello"

...is permanently broken too now with the same error as above, despite working moments before. Strange.

It's enterprise, so we are logged in via ghe.com.

Running a regular "copilot" is fine.

Version: 1.0.81

Can you please fix this latest blocking login bug. There should be no differing auth code paths just because of a -p or --agent parameter.

I suspect you've hardcoded or chosen api.githubcopilot.com incorrectly again (if so, please add some effective guardrails to prevent this, this is a repeated root cause of various login issues).

Affected version

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

Additional context

No response

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先,在 ghe.com Enterprise 环境中使用 -p--agent/login 命令,通过 copilot CLI 复现该故障;将其行为与交互式运行 copilot 时的行为进行比较,并检查 gh auth status。当 -p--agent 都使用正确的 Enterprise 身份验证路径,且不影响后续命令时,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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