opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Github copilot failing to authorize

Open hamir-certain opened this issue 3 weeks ago • 10 comments

Description

So I'm having issues authorizing opencode with github copilot, the authorization gets stopped very quickly. I also had issues authenticating the gh cli with github so I suspect this is the same issue as: https://github.com/cli/cli/issues/9370

Since this is the issue I've had when using gh auth login, for gh cli it's possible to work around the issue as described in comments (basically by being quick and copying the code beforehand). one solution is to have the challange code shown before you start pooling github.

with debug logs:

opencode auth login --log-level DEBUG --print-logs
INFO  2026-01-14T22:59:13 +235ms service=default version=1.1.20 args=["auth","login","--log-level","DEBUG","--print-logs"] opencode
INFO  2026-01-14T22:59:13 +0ms service=default directory=/home/osboxes/Documents/semaphore/semaphore creating instance
INFO  2026-01-14T22:59:13 +0ms service=project directory=/home/osboxes/Documents/semaphore/semaphore fromDirectory

┌  Add credential
INFO  2026-01-14T22:59:13 +17ms service=models.dev file={} refreshing
INFO  2026-01-14T22:59:13 +106ms service=config path=/home/osboxes/.config/opencode/config.json loading
INFO  2026-01-14T22:59:13 +0ms service=config path=/home/osboxes/.config/opencode/opencode.json loading
INFO  2026-01-14T22:59:13 +0ms service=config path=/home/osboxes/.config/opencode/opencode.jsonc loading
INFO  2026-01-14T22:59:13 +2ms service=bun cmd=["/home/osboxes/.opencode/bin/opencode","add","@opencode-ai/[email protected]","--exact"] cwd=/home/osboxes/.config/opencode running
DEBUG 2026-01-14T22:59:13 +1ms service=config loading config from /home/osboxes/.opencode/opencode.jsonc
INFO  2026-01-14T22:59:13 +0ms service=config path=/home/osboxes/.opencode/opencode.jsonc loading
DEBUG 2026-01-14T22:59:13 +1ms service=config loading config from /home/osboxes/.opencode/opencode.json
INFO  2026-01-14T22:59:13 +0ms service=config path=/home/osboxes/.opencode/opencode.json loading
INFO  2026-01-14T22:59:13 +0ms service=bun cmd=["/home/osboxes/.opencode/bin/opencode","add","@opencode-ai/[email protected]","--exact"] cwd=/home/osboxes/.opencode running
INFO  2026-01-14T22:59:13 +11ms service=models.dev file={} refreshing
INFO  2026-01-14T22:59:13 +1ms service=bun code=0 stdout=bun add v1.3.5 (1e86cebd)

installed @opencode-ai/[email protected]

[3.00ms] done
 stderr=Saved lockfile
 done
INFO  2026-01-14T22:59:13 +0ms service=bun cmd=["/home/osboxes/.opencode/bin/opencode","install"] cwd=/home/osboxes/.config/opencode running
INFO  2026-01-14T22:59:13 +0ms service=bun code=0 stdout=bun add v1.3.5 (1e86cebd)

installed @opencode-ai/[email protected]

[2.00ms] done
 stderr=Saved lockfile
 done
INFO  2026-01-14T22:59:13 +1ms service=bun cmd=["/home/osboxes/.opencode/bin/opencode","install"] cwd=/home/osboxes/.opencode running
│
◆  Select provider

│  Search: _
│  ● OpenCode Zen (recommended)
│  ○ Anthropic
│  ○ GitHub Copilot
│  ○ OpenAI
│  ○ Google
◇  Select provider
│  GitHub Copilot
INFO  2026-01-14T22:59:16 +2982ms service=plugin name=CodexAuthPlugin loading internal plugin
INFO  2026-01-14T22:59:16 +0ms service=plugin [email protected] loading plugin
INFO  2026-01-14T22:59:16 +3ms service=plugin [email protected] loading plugin
INFO  2026-01-14T22:59:16 +16ms service=plugin path=@gitlab/[email protected] loading plugin
│
◇  Select GitHub deployment type
│  GitHub.com
│
●  Go to: https://github.com/login/device
│
●  Enter code: A70D-8000
│
■  Failed to authorize
│
└  Done

Plugins

No response

OpenCode version

1.1.20

Steps to reproduce

I don't think this can be easily reproduced as it's environment specific. Guys over on https://github.com/cli/cli/issues/9370 couldn't reproduce it

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04 (vm on Windows host)

Terminal

Gnome Terminal

hamir-certain avatar Jan 14 '26 23:01 hamir-certain

This issue appears to be unique in our repository - it's specifically about the device flow authorization timing out too quickly during GitHub Copilot authentication.

While we don't have an exact duplicate, you may find the following related issues useful for context on GitHub Copilot authentication challenges:

  • #8030: Copilot auth now sets far too many requests as "user" consuming premium requests rapidly
  • #8297: Plugin installation failures are silent, causing OAuth options to disappear
  • #6261: Multiple plugins registering auth for the same provider silently overwrite each other

The core issue you're experiencing aligns with the gh CLI issue you referenced (cli/cli#9370), which suggests this might be an upstream GitHub API limitation or browser behavior related to the device flow timeout.

If you're able to gather any additional environment-specific debugging information (browser logs, network timing, exact timeout duration), it would help in diagnosing whether this is a client-side or server-side timeout issue.

github-actions[bot] avatar Jan 14 '26 23:01 github-actions[bot]

commenting so u know i saw this

rekram1-node avatar Jan 14 '26 23:01 rekram1-node

Hey, also noticed this issue today:

INFO  2026-01-15T17:03:29 +1714ms service=plugin name=CodexAuthPlugin loading internal plugin
INFO  2026-01-15T17:03:29 +1ms service=plugin name=CopilotAuthPlugin loading internal plugin
INFO  2026-01-15T17:03:29 +0ms service=plugin [email protected] loading plugin
INFO  2026-01-15T17:03:29 +30ms service=plugin path=@gitlab/[email protected] loading plugin
ERROR 2026-01-15T17:03:33 +3286ms service=default name=Error message=Failed to initiate device authorization stack=Error: Failed to initiate device authorization
    at authorize (src/plugin/copilot.ts:172:25)
    at processTicksAndRejections (native:7:39) fatal

when running opencode auth login on 1.1.21, having Brave as default browser - could also be related to a Github API outage?

https://www.githubstatus.com/

DennisLoska avatar Jan 15 '26 17:01 DennisLoska

Is there anything special about your environment? Idk what is failing for u

rekram1-node avatar Jan 15 '26 17:01 rekram1-node

Found it! So the problem was running the command within my tmux session! After detaching and trying it worked (same for gh cli btw`)!

DennisLoska avatar Jan 15 '26 17:01 DennisLoska

Interesting, I'm using i3wm, but I really can't see how that can cause this

hamir-certain avatar Jan 15 '26 17:01 hamir-certain

You can auth in tui btw,

opencode

then /connect

rekram1-node avatar Jan 15 '26 17:01 rekram1-node

Yeah I've initially tried that, it just closes the overlay (I guess same error happens)

https://github.com/user-attachments/assets/dc9e32e2-4a5c-4e23-981b-97d7b3f28e6e

hamir-certain avatar Jan 15 '26 19:01 hamir-certain

hmmm

rekram1-node avatar Jan 15 '26 21:01 rekram1-node

I'll try the new version of the gh cli ad they've released a version containing this fix https://github.com/cli/oauth/commit/f0230b88d1996ab1237f69a7c42ea228a6cfc4ac If that works I'll try building opencode with a modified copilot plugin, handling the slow_down response might do the trick.

hamir-certain avatar Jan 15 '26 23:01 hamir-certain