Github copilot token does not renew, after it expires
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Describe the bug Github copilot token does not renew, after it expires I need to /login again.
To Reproduce Steps to reproduce the behavior (linux):
- open eca in emacs
- enter /login + github-copilot
- authenticate with browser and confirm new token with new expires-at is present under
~/.cache/eca/db.transit.json - After
expires-ateca chat window returns "invalid token 401" and I need to authenticate again
Expected behavior
- token is refreshed after
refresh_in, value returned from https://api.github.com/copilot_internal/v2/token when eca daemon is running. - https://api.github.com/copilot_internal/v2/token is used to issue new token (using access token) if we're past
expires_at
Doctor
> /doctor
ECA version: 0.56.2
Server cmd: /home/user/.emacs.d/eca/eca server
Default model: github-copilot/gpt-5
Login providers:
anthropic: {}
azure: {}
deepseek: {}
github-copilot: {:step :login/done, :device-code "ec7*****009", :access-token
"ghu*****jhK", :api-key "tid*****4c5", :expires-at 1758357397}
openai: {}
openrouter: {}
z-ai: {}
Relevant env vars:
DEBUGINFOD_URLS=https://debuginfod.ubuntu.com
Additional context
I'm honestly not sure if this is a bug or missing feature. I reported this as a bug because I found this commit: https://github.com/editor-code-assistant/eca/commit/1ad87dceaf8fd55adeb7a95c7065fb092d137225 commit message says: Fix token expiration for copilot and anthropic., but no copilot files were modified.
@mspik that's weird, I just tested that and it's working as expected, one easy way to repro the expiration is to edit ~/.cache/eca/db.transit.json, and remove some numbers from expires_at at github-copit section, then restart ECA and on next request ECA will check and see timestamp has passed and renew the token here
Ah I managed to repro the issue, it seems to happen only with native image compiled ECA, I will take a look how to fix
@mspik it was related to a bug I already had fixed on master, just released 0.56.3, which fixes that, LMK otherwise.
@ericdallo I can confirm it works for me now, but with one minor issue (which does not bother much to be honest), my scenario:
- /login + github-copilot
- 30 minut passes, my token expires, I check db.transit.json,
expires-atstays unchanged - I send another prompt and I get
LLM response status: 401 body: unauthorized: token expired - now I check db.transit.json again and I see new token with new
expires-at - I repeat the same prompt and it works
thank you for your quick response and new version 0.56.3
@mspik thanks for the feedback, I fixed this other issue on 0.56.4!
I confirm, works perfect now, thank you!
I'm still getting this error, and it tends to occur in the middle of long agentic workflows:
LLM response status: 401 body: unauthorized: token expired
It interrupts the task, but the session remains intact so that I can ask the agent to continue. Could it be that token is checked and refreshed on user input but not on intermediate steps during the process?
@itkonen Yeah, I mentioend about it here, I believe github has a limit of how much can use the x-initiator as agent until needs to consume other premium request (x-initiator: user), that's why you sending the prompt works because user prompt goes as user.
We should double check how copilot does on their side and do the same here, but my guess ist that use user when get that 401, feel free to open a new issue about it to help track/prioritize