opencode
opencode copied to clipboard
Github Enterprise authorization
Description
Got an Unexpected Error while trying to login with a Github Enterprise login:
┌ Add credential
│
◇ Select provider
│ GitHub Copilot
│
◇ Select GitHub deployment type
│ GitHub Enterprise
│
◇ Enter your GitHub Enterprise URL or domain
│ https://github.my-company-domain.com
Error: Unexpected error, check log file at /home/remo/.local/share/opencode/log/2025-11-05T113425.log for more details
192 | scope: "read:user",
193 | }),
194 | });
195 |
196 | if (!deviceResponse.ok) {
197 | throw new Error("Failed to initiate device authorization");
^
error: Failed to initiate device authorization
at authorize (/home/remo/.cache/opencode/node_modules/opencode-copilot-auth/index.mjs:197:25)
at processTicksAndRejections (native:7:39)
I can login to my company Github via web just fine. The actual name of the company has been hidden for privacy reason.
The last lines of the log file are:
INFO 2025-11-05T11:34:27 +5ms service=plugin [email protected] loading plugin
INFO 2025-11-05T11:34:27 +15ms service=plugin [email protected] loading plugin
ERROR 2025-11-05T11:34:44 +17640ms service=default name=Error message=Failed to initiate device authorization stack=Error: Failed to initiate device authorization
at authorize (/home/remo/.cache/opencode/node_modules/opencode-copilot-auth/index.mjs:197:25)
at processTicksAndRejections (native:7:39) fatal
OpenCode version
10.0.25
Steps to reproduce
- run "opencode auth login"
- choose "Github Copilot"
- choose "GitHub Enterprise"
- enter the doain name "https://github.my-company-domain.com" (actual domain hidden for privacy reasons)
Screenshot and/or share link
No response
Operating System
Windows 11 + WSL2 Ubuntu 24.04
Terminal
Windows Terminal
This issue might be a duplicate of existing issues. Please check:
- #664: Support Github Copilot Enterprise provider - specifically addresses the lack of GitHub Enterprise support for Copilot authentication
- #355: enhancement: support ghe.com copilot auth - requests support for GitHub Enterprise Copilot auth
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 tried with:
- https://github.my-company.com
- github.my-company.com
- my-company.ghe.com
- my-company.com
- my-company
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"
Im gonna fix this today Ik the bug
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?
yeah i think ur right