You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both of these existing issues highlight that OpenCode currently only supports Copilot auth using the standard github.com domain, which appears to be the root cause of your "Failed to initiate device authorization" error when trying to use your GitHub Enterprise domain.
Feel free to ignore if none of these address your specific case.
i would need to have a second glance at rhe code, but for domain name are you including an https prefix? I think it is looking just for the domain name not the url
I access my company GitHub with: https://github.my-company.com and I checked that the htts:://github.my-company.com/login/device works properly.
The URL copilot-api.github.my-company.com and api.github.my-company.com do NOT work (not sure if they should, I just checked).
The URL https://api.my-company.ghe.com/ returns "Couldn't find Business with slug = my-company"
Great! In the meantime I noticed that I can login to github.com using my company name: "name-surname_cmpny"
the "_cmpny" at the end triggers the SSO with my company and I can login exactly as I had used "https://github.cmpny.com/"
Maybe is a different type of integration than having a "ghe.com" name?
# Test with opencode run (non-interactive)
opencode run --model github-copilot-enterprise/claude-opus-4.6 "Say SUCCESS"# Expected: "> build · claude-opus-4.6\nSUCCESS"
Hello @rekram1-node I have the an issue related to authorization when trying to connect Github Copilot Enterprise after entering my company github domain in the tui:
Setup:
Device: Mac M4 OS - Tahoe 26.4.1
Terminal: Kitty
OpenCode version: 1.14.31
Default browser: Brave (Tried Safari as well)
Logs:
INFO 2026-05-05T07:33:59 +143ms service=default version=1.14.31 args=["auth","login"] process_role=main run_id=6e424fb1-1629-4934-b48e-effebde6e7d2 opencode
INFO 2026-05-05T07:33:59 +0ms service=default directory=/Users/athauvin creating instance
INFO 2026-05-05T07:33:59 +2ms service=project directory=/Users/athauvin fromDirectory
INFO 2026-05-05T07:33:59 +2ms service=db path=/Users/athauvin/.local/share/opencode/opencode.db opening database
INFO 2026-05-05T07:33:59 +4ms service=db count=14 mode=bundled applying migrations
ERROR 2026-05-05T07:33:59 +115ms service=models.dev error=unable to get local issuer certificate Failed to fetch models.dev
ROR 2026-05-05T07:33:59 +87ms service=models.dev error=unable to get local issuer rtificate Failed to fetch models.dev
INFO 2026-05-05T07:33:59 +8ms service=file init
INFO 2026-05-05T07:34:00 +24ms service=config path=/Users/athauvin/.config/opencode/config.json loading
INFO 2026-05-05T07:34:00 +0ms service=config path=/Users/athauvin/.config/opencode/opencode.json loading
INFO 2026-05-05T07:34:00 +0ms service=config path=/Users/athauvin/.config/opencode/opencode.jsonc loading
INFO 2026-05-05T07:34:00 +16ms service=plugin name=cH loading internal plugin
INFO 2026-05-05T07:34:00 +0ms service=plugin name=sH loading internal plugin
INFO 2026-05-05T07:34:00 +0ms service=plugin name=zj loading internal plugin
INFO 2026-05-05T07:34:00 +0ms service=plugin name=FZ loading internal plugin
INFO 2026-05-05T07:34:00 +0ms service=plugin name=Fj loading internal plugin
INFO 2026-05-05T07:34:00 +0ms service=plugin name=wj loading internal plugin
INFO 2026-05-05T07:34:00 +0ms service=plugin name=Uj loading internal plugin
INFO 2026-05-05T07:34:00 +1ms service=bus type=* subscribing
ERROR 2026-05-05T07:34:05 +5651ms service=default name=Error message=Failed to initiate device authorization stack=Error: Failed to initiate device authorization
at authorize (/$bunfs/root/chunk-7kndgn7w.js:521:12699)
at processTicksAndRejections (native:7:39) fatal
Activity
github-actions commentedon Nov 5, 2025
This issue might be a duplicate of existing issues. Please check:
Both of these existing issues highlight that OpenCode currently only supports Copilot auth using the standard github.com domain, which appears to be the root cause of your "Failed to initiate device authorization" error when trying to use your GitHub Enterprise domain.
Feel free to ignore if none of these address your specific case.
rekram1-node commentedon Nov 5, 2025
i would need to have a second glance at rhe code, but for domain name are you including an https prefix? I think it is looking just for the domain name not the url
rdentato commentedon Nov 5, 2025
I tried with:
I access my company GitHub with: https://github.my-company.com and I checked that the htts:://github.my-company.com/login/device works properly.
The URL copilot-api.github.my-company.com and api.github.my-company.com do NOT work (not sure if they should, I just checked).
The URL https://api.my-company.ghe.com/ returns "Couldn't find Business with slug = my-company"
rekram1-node commentedon Nov 10, 2025
Im gonna fix this today Ik the bug
rdentato commentedon Nov 12, 2025
Great! In the meantime I noticed that I can login to github.com using my company name: "name-surname_cmpny"
the "_cmpny" at the end triggers the SSO with my company and I can login exactly as I had used "https://github.cmpny.com/"
Maybe is a different type of integration than having a "ghe.com" name?
rekram1-node commentedon Nov 12, 2025
yeah i think ur right
jolo-dev commentedon Jan 3, 2026
Any progress on this? I am facing the same issue!
maaaark commentedon Jan 15, 2026
I am having the same issue login to ghe.com..
Also there is no way to login the ghe.com in the GUI right? Only by TUI?
Here is the auth with logs:
` opencode --print-logs auth login
INFO 2026-01-15T18:29:01 +202ms service=default version=1.1.22 args=["--print-logs","auth","login"] opencode
INFO 2026-01-15T18:29:01 +0ms service=default directory=D:\web\trails creating instance
INFO 2026-01-15T18:29:01 +0ms service=project directory=D:\web\trails fromDirectory
┌ Add credential
INFO 2026-01-15T18:29:01 +31ms service=models.dev file={} refreshing
INFO 2026-01-15T18:29:02 +163ms service=config path=C:\Users\markt.config\opencode\config.json loading
INFO 2026-01-15T18:29:02 +0ms service=config path=C:\Users\markt.config\opencode\opencode.json loading
INFO 2026-01-15T18:29:02 +0ms service=config path=C:\Users\markt.config\opencode\opencode.jsonc loading
INFO 2026-01-15T18:29:02 +3ms service=bun cmd=["C:\Users\markt\AppData\Roaming\npm\node_modules\opencode-ai\node_modules\opencode-windows-x64\bin\opencode.exe","add","@opencode-ai/plugin@1.1.22","--exact"] cwd=C:\Users\markt.config\opencode running
INFO 2026-01-15T18:29:02 +10ms service=models.dev file={} refreshing
│
◆ Select provider
│ Search: _
│ ● OpenCode Zen (recommended)
│ ○ Anthropic
│ ○ GitHub Copilot
│ ○ OpenAI
│ ○ Google
│ ○ OpenRouter
│ ○ Vercel AI Gateway
│ ...
◇ Select provider
│ GitHub Copilot
INFO 2026-01-15T18:29:31 +29545ms service=plugin name=CodexAuthPlugin loading internal plugin
INFO 2026-01-15T18:29:31 +0ms service=plugin name=CopilotAuthPlugin loading internal plugin
INFO 2026-01-15T18:29:31 +0ms service=plugin path=opencode-anthropic-auth@0.0.9 loading plugin
INFO 2026-01-15T18:29:31 +21ms service=plugin path=@gitlab/opencode-gitlab-auth@1.3.0 loading plugin
│
◇ Select GitHub deployment type
│ GitHub Enterprise
│
◇ Enter your GitHub Enterprise URL or domain
│ https://XXXXXXXXXXX.ghe.com
ERROR 2026-01-15T18:29:54 +22115ms 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
Error: Unexpected error, check log file at for more details
Failed to initiate device authorization`
Any help or hint would be nice :)
rekram1-node commentedon Jan 15, 2026
working w/ copilot team to get this figured out
36 remaining items
davidraehles commentedon Feb 18, 2026
@WilliamWelsh ran into the same issue afterwards. But Opus 4.6 found a fix:
Complete Working Solution
The fix requires two pieces working together:
Piece 1: JWT Refresh Cron Job
Since OpenCode doesn't do token exchange and its OAuth app is rejected by the token exchange endpoint, a cron job exchanges the token externally:
01ab8ac9400c4e429b23)gho_token for a Copilot JWTauth.jsonPiece 2:
Editor-VersionHeader viaopencode.jsonThe Copilot API requires
Editor-Versionfor JWT auth. Add per-model headers:{ "provider": { "github-copilot-enterprise": { "models": { "claude-opus-4.6": { "headers": { "Editor-Version": "vscode/1.100.0", "Copilot-Integration-Id": "vscode-chat" } }, "claude-sonnet-4": { "headers": { "Editor-Version": "vscode/1.100.0", "Copilot-Integration-Id": "vscode-chat" } }, "gpt-5": { "headers": { "Editor-Version": "vscode/1.100.0", "Copilot-Integration-Id": "vscode-chat" } }, "gpt-5-mini": { "headers": { "Editor-Version": "vscode/1.100.0", "Copilot-Integration-Id": "vscode-chat" } }, "gemini-2.5-pro": { "headers": { "Editor-Version": "vscode/1.100.0", "Copilot-Integration-Id": "vscode-chat" } } } } } }Verification
WilliamWelsh commentedon Feb 18, 2026
@davidraehles that worked!
{ "$schema": "https://opencode.ai/config.json", "provider": { "github-copilot-enterprise": { "models": { "gpt-5.2-codex": { "headers": { "Editor-Version": "vscode/1.100.0", "Copilot-Integration-Id": "vscode-chat" } }, "gpt-5.3-codex": { "headers": { "Editor-Version": "vscode/1.100.0", "Copilot-Integration-Id": "vscode-chat" } } } } } }Hopefully this entire issue is resolved eventually so I don't have to run this daemon script and manually add models like this, but thanks!
rekram1-node commentedon Feb 19, 2026
The reason it worked is because of this:
We are not allowed to use that id.
Still waiting for full enterprise rollout but I will keep yall posted. Nothing left on our end we wait for github ppl.
WilliamWelsh commentedon Mar 16, 2026
1 month later ;-;
is there anyone at GitHub we can ping? seems kind of crazy considering how popular OpenCode is
rekram1-node commentedon Mar 16, 2026
@WilliamWelsh can u test this branch? Ill merge it later:
#17847
u should be able to test w/
bunx opencode-ai@betaOr using npm or pnpm
rekram1-node commentedon Mar 16, 2026
There may be bugs I just don't have a way to test, and to login w/ copilot enterprise use
opencode auth logininstead of /connectWilliamWelsh commentedon Mar 16, 2026
@rekram1-node Appears to be working! I even removed my
opencode.jsonwhich had thevscode-chatstuffrekram1-node commentedon Mar 16, 2026
Sweet! Okay ill add /connect support for it too then (so that it prompts u for enterprise)
Thanks for helping me out
Raviguntakala commentedon Mar 17, 2026
@rekram1-node I already created a PR #6974 for this one long back. If you want to use this one, I can resolve conflicts
STSMHQ commentedon Mar 17, 2026
Thanks a lot, guys! This is great.
rekram1-node commentedon Mar 17, 2026
Ill take a look at the pr, the conditional thingy is a little weird to do over http so ill check ur implementation
jolo-dev commentedon Mar 18, 2026
It seems to work. I can access all models from our enterprise subscription following their docs
https://opencode.ai/docs/providers/#github-copilot
rekram1-node commentedon Mar 18, 2026
next release should have /connect support working properly.
that will close out this issue
alexandre-thauvin commentedon May 5, 2026
Hello @rekram1-node I have the an issue related to authorization when trying to connect Github Copilot Enterprise after entering my company github domain in the tui:
Setup:
Device: Mac M4 OS - Tahoe 26.4.1
Terminal: Kitty
OpenCode version: 1.14.31
Default browser: Brave (Tried Safari as well)
Logs: