anomalyco / anomalyco/opencode

GitHub Copilot provider fails silently on Linux (v1.18.13) — OAuth token missing copilot scope, no models registered

Open
#40,828 2 comments 2 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 6, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Description
On Linux (Kali, ARM64, via npm install -g opencode-ai), the GitHub Copilot login flow (/connect → github) completes without any visible error, but the resulting OAuth token is never exchanged for a valid Copilot session token. As a result, opencode models lists zero github-copilot/* models, and forcing a model explicitly with -m github-copilot/ fails with a generic UnknownError.
The exact same GitHub account works correctly with OpenCode v1.14.33 on macOS — same account, same Copilot Student entitlement, fully functional. Downgrading to v1.14.33 on the same Linux machine fixes the issue completely, strongly suggesting a regression introduced between 1.14.33 and 1.18.13 specifically affecting the github-copilot provider's OAuth flow.

Environment
Broken: OpenCode v1.18.13, Kali Linux (ARM64, UTM/QEMU VM), installed via npm install -g opencode-ai
Working: OpenCode v1.14.33, macOS
Same GitHub account (Copilot Individual, Student educational quota) in both cases

Steps to reproduce (on v1.18.13 / Linux)
opencode → /connect → select GitHub → complete device flow in browser
Login appears to succeed (no error shown)
opencode models → no github-copilot/* entries appear in the list
opencode run -m github-copilot/claude-sonnet-4.5 "hi" → fails
Root cause (confirmed via manual diagnosis)
Inspecting ~/.local/share/opencode/auth.json after login:
json
"github-copilot": {
"type": "oauth",
"access": "gho_...",
"refresh": "gho_...", // identical to access
"expires": 0
}
access and refresh are identical — the raw GitHub OAuth token from the device flow, never exchanged for a real Copilot session token.
expires: 0 — no real expiry was ever set, confirming the exchange step never completed.
Checking the token's scope directly:
curl -sI -H "Authorization: token gho_..." https://api.github.com/user | grep -i scope
→ x-oauth-scopes: read:user
The device flow only requests read:user. It appears to never request whatever scope/authorization is needed for GitHub to allow the client_id used by OpenCode to call the Copilot token-exchange endpoint.
Confirmed the token itself is otherwise valid (/user returns correct account info, Copilot entitlement confirmed via /copilot_internal/user with a separately-generated fine-grained PAT — chat_enabled: true, cli_enabled: true, plan individual).
Calling the actual exchange endpoint manually with this token always returns 404:
curl -s -H "Authorization: token gho_..." https://api.github.com/copilot_internal/v2/token
→ {"message":"Not Found","documentation_url":"https://docs.github.com/rest","status":"404"}
This reproduced identically across two separate fresh logins (including after fully revoking the OAuth grant from GitHub's side and reconnecting from scratch) — not a one-off token issue.
For comparison, the official GitHub copilot CLI (installed via gh copilot) authenticates successfully and works out of the box on the same machine, same account — so this is not an account/entitlement/network problem, it's specific to how OpenCode's github-copilot provider performs its OAuth handshake in this version.
Fix / workaround

Downgrading resolves it completely:
bash
npm install -g opencode-ai@1.14.33
After re-running /connect, opencode models correctly lists the full github-copilot/* catalog (Claude Sonnet/Opus, GPT-5.x, Gemini, etc.) and inference works.
Expected behavior
The device-flow OAuth login for the github-copilot provider should request whatever scope/authorization GitHub requires, complete the token exchange automatically after login, and populate opencode models with the available Copilot models — as it does correctly in v1.14.33.

Plugins

No response

OpenCode version

1.18.13

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.