#4364: fix(github-copilot): use gho_ tokens directly without exchange
docs
Cluster:
GitHub Copilot Enhancements
Tokens from the GitHub Copilot CLI (prefixed with `gho_`) can be used directly with the Copilot API without requiring a token exchange via /copilot_internal/v2/token (which returns HTTP 404 for these tokens).
This fixes authentication for users who:
- Installed the Copilot CLI (`npm install -g @github/copilot`)
- Authenticated via `copilot auth login`
- Set COPILOT_GITHUB_TOKEN or GH_TOKEN to their gho_ token
The fix detects gho_ prefixed tokens and skips the exchange, caching them with an 8-hour TTL (matching typical OAuth token lifetimes).
Also adds COPILOT_API_BASE_URL env var support for enterprise users whose proxy blocks api.individual.githubcopilot.com. Set this to your enterprise endpoint (e.g., https://api.business.githubcopilot.com).
[AI-assisted] Tested with GitHub Copilot CLI 0.0.399 on WSL2.
Related to #3437
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the GitHub Copilot token resolution flow to special-case `gho_` tokens (from the Copilot CLI) so they are used directly without calling GitHub’s `/copilot_internal/v2/token` exchange endpoint. It also introduces support for overriding the Copilot API base URL via `COPILOT_API_BASE_URL` (useful for enterprise/proxy scenarios), adds tests for the new behavior, and extends log redaction patterns to cover `gho_` tokens.
The change primarily lives in `src/providers/github-copilot-token.ts`, which is used by provider discovery (`src/agents/models-config.providers.ts`) to resolve the correct Copilot base URL and token source, with docs updated to describe the new auth path.
<h3>Confidence Score: 3/5</h3>
- This PR is mostly safe to merge, but there’s a functional edge case around base URL selection for cached `gho_` tokens and a doc rendering issue.
- The core change (skipping token exchange for `gho_` tokens) is small and covered by new unit tests, and log redaction is a straightforward addition. However, the cache-hit path currently ignores `COPILOT_API_BASE_URL`, which can break enterprise setups after the first run, and the docs appear to have escaped code fences which reduces usability.
- src/providers/github-copilot-token.ts; docs/providers/github-copilot.md
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#13505: feat(copilot): add GitHub Enterprise Cloud (GHE.com) support for Co...
by kryptus47 · 2026-02-10
87.1%
#11782: fix: resolve 403 auth error for GithubCopilot imageModel (#10277)
by adamkoncz · 2026-02-08
83.3%
#8805: [Bug Fix][AI-assisted] Refresh Copilot token before expiry and retr...
by Arthur742Ramos · 2026-02-04
82.0%
#22352: fix(auth): validate Copilot token cache belongs to requesting account
by xinhuagu · 2026-02-21
80.8%
#8467: fix(github-copilot): add configurable IDE headers + fix null filtering
by ericchansen · 2026-02-04
80.4%
#15044: fix: refresh GitHub Copilot default model list
by Godzilla675 · 2026-02-12
77.4%
#2657: fix: use TLS 1.2 for gemini-cli and google-antigravity OAuth reques...
by PrentissLiu · 2026-01-27
74.8%
#7781: fix: resolve Google Gemini CLI auth credential extraction #4585
by ManojPanda3 · 2026-02-03
74.4%
#3909: fix(auth): refresh all OAuth profiles per provider
by Daviey · 2026-01-29
74.1%
#5064: fix(auth): update deprecated User-Agent headers
by mfortin014 · 2026-01-31
73.7%