eca icon indicating copy to clipboard operation
eca copied to clipboard

Allow GitHub CoPilot authentication over GHE

Open mgmart opened this issue 7 months ago • 22 comments

It would be nice if I could use ECA also with my GitHub Enterprise account (subdomain.ghe.com).

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

mgmart avatar Apr 08 '26 14:04 mgmart

@mgmart did you try setting env GITHUB_COPILOT_API_URL?

code ref

ericdallo avatar Apr 08 '26 14:04 ericdallo

@ericdallo, yeah. I tried api.mysbdmn.ghe.com and also mysbdmn.ghe.com

I would assume that GITHUB_COPILOT_API_URL does not affect the initial authentication. The handshake with device-code-login seems to be hardwired with github.com.

mgmart avatar Apr 08 '26 15:04 mgmart

Ah yes, the auth flow is hardcoded, we could check the url as well if they are equal, if we have the details I can do the change

ericdallo avatar Apr 08 '26 16:04 ericdallo

I would assume that should be configurable. As far as I know, every enterprise has its own subdomain in GHE.

mgmart avatar Apr 08 '26 16:04 mgmart

@mgmart do you know if clientId changes by subdomain? I believe not, but I think it's not the same for GHE

ericdallo avatar Apr 08 '26 17:04 ericdallo

@mgmart just added providers github-copilot auth url and providers github-copilot auth clientId configs, being clientId optional if the default not works, can you try later?

ericdallo avatar Apr 08 '26 18:04 ericdallo

@ericdallo, that was fast. Thank you. I'm using eca from homebrew at the moment. I think I will have time at the weekend to compile it from source.

mgmart avatar Apr 08 '26 18:04 mgmart

I just did a release 0.124.3 which includes that!

ericdallo avatar Apr 08 '26 18:04 ericdallo

I made a quick try. Auth has worked. When trying to chat I get OpenAI errors. Not quite sure why this happens. I will give it a try the next days. It's too late to make a focussed trial and error session 😫 Anyway. I think the authentication was the main hurdle. Thanks again!

mgmart avatar Apr 08 '26 19:04 mgmart

@ericdallo, I get:

LLM response status: 401 body: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}

could that be the clientID? I haven't configured any, would not know where to get the vaue from.

Here is the full output, slightly redacted. There was nothing in stderr.

For other providers, configure manually in your ECA config.
>  github-copilot

First, make sure you have Copilot enabled in your Github account: https://xxx.ghe.com/settings/copilot/features
Then, open your browser at:

https://xxx.ghe.com/login/device

Authenticate using the code: `xxxx-xxxx`
Then type anything in the chat and send it to continue the authentication.

> Hello 

Login successful! You can now use the 'github-copilot' models.

Make sure to enable the model you want to use at: https://xxx.ghe.com/settings/copilot/features

> Hello

LLM response status: 401 body: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}

mgmart avatar Apr 09 '26 05:04 mgmart

@mgmart it should be fixed on 0.124.4! The auth flow returns the proper url to do the requests, I updated to use that, LMK if works

ericdallo avatar Apr 09 '26 13:04 ericdallo

only 0.124.3 @ homebrew at the moment (16:58:56 CEST)

mgmart avatar Apr 09 '26 15:04 mgmart

@ericdallo, I downloaded it from the release-page. It works!

mgmart avatar Apr 09 '26 15:04 mgmart

But™️

[MODELS] Provider 'github-copilot': /models endpoint returned status 401

mgmart avatar Apr 09 '26 15:04 mgmart

@mgmart there was a missing place for models fetch, fixed in 0.124.5!

ericdallo avatar Apr 09 '26 16:04 ericdallo

eca-emacs: 20260404.1817 | server: eca 0.124.5 | emacs: GNU Emacs 30.2 (build 1, aarch64-apple-darwin23.2.0, NS appkit-2487.30 Version 14.2 (Build 23C64)) of 2025-12-06

on load

[MODELS] Provider 'github-copilot': /models endpoint returned status 401

when using select model

[MODELS] Provider 'github-copilot': /models endpoint returned status 400

mgmart avatar Apr 10 '26 05:04 mgmart

you can configure any model you want like this:

{
  "providers": {
    "github-copilot": {
      "models": { 
        "gpt-5.4": {}
      }
    }
  }
}

But the auto fetch models is suppose to work, probably we are missing something yet for GHE 🤔 @zikajk any clues? @mgmart feel free to open a new issue about this specific issue, to help track/fix it

ericdallo avatar Apr 10 '26 13:04 ericdallo

@ericdallo Before the change I had got 400, now I have 401. I think I know what is the problem. I have fixed it in one of my unfinished branch (where I'd want to add model variants for Copilot and also dynamically determine the required API type). I almost forgot about that, I'll try to finish it up sometime soon.

@mgmart But it is functional for you at the moment, correct? Since your models are sourced from models.dev, you don't have an acute need for this?

zikajk avatar Apr 11 '26 17:04 zikajk

@zikajk, no need for the moment because I can use the configuration option, @ericdallo provided yesterday.

But from what I see, models.dev is not used for github-copilot, only for anthropic, openai and google.

[MODELS] Provider 'google': /models endpoint returned status 400
[MODELS] Provider 'google': Using models.dev provider-id fallback (url 'https://generativelanguage.googleapis.com/v1beta/openai' not matched)
[MODELS] Provider 'google': Loaded 37 models from models.dev
[MODELS] Provider 'anthropic': /models endpoint returned status 401
[MODELS] Provider 'anthropic': Using models.dev provider-id fallback (url 'https://api.anthropic.com' not matched)
[MODELS] Provider 'anthropic': Loaded 22 models from models.dev
[MODELS] Provider 'openai': /models endpoint returned status 401
[MODELS] Provider 'openai': Using models.dev provider-id fallback (url 'https://api.openai.com' not matched)
[MODELS] Provider 'openai': Loaded 51 models from models.dev
[MODELS] Provider 'github-copilot': /models endpoint returned status 401
[MODELS] Fetched model catalogs from 3 providers in 271.1ms
[LLM-API] Default LLM model 'github-copilot/gpt-5.4' decision ':config-default-model'

mgmart avatar Apr 11 '26 17:04 mgmart

@mgmart we use models.dev for any configured provider to auto fetch models, unless fetchModels config is false

ericdallo avatar Apr 12 '26 17:04 ericdallo