vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

VSCode Tunnel expires after 24 hours and have an error on refreshing the token.

Open aleleba opened this issue 3 months ago • 13 comments

I am getting every 24 hours this error:

Right now every 24 hours I am getting this issue: [2025-09-17 15:02:56] info error refreshing token: error requesting https://api.github.com/user: 401 {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"} I am having issues with my remote tunnel and I started like this code tunnel --accept-server-license-terms --name ${VSCODE_TUNNEL_NAME}

  • VSCode Version:
  • Local OS Version:
  • Remote OS Version:
  • Remote Extension/Connection Type: Dev Containers/WSL/Remote - Tunnels/VS Code Server
  • Logs:

Steps to Reproduce:

  1. Create a remote tunnel and logging with github
  2. The tunnel failed to update the refresh token

It was working perfectly, I suggest to add a headless way to create this tunnel with github authentication

This is a very bad issue for me, I will give a talk on Saturday about how to use this vscode tunnels and I can not show this failing please take this as an priority bug.

Does this issue occur when you try this locally?: Yes Does this issue occur when you try this locally and all extensions are disabled?: Yes

aleleba avatar Sep 17 '25 18:09 aleleba

@connor4312 @bamurtaugh can you check this? Thank you in advance. Giving some context this was not happening before I can have a vscode tunnel running without any issue during months. I am tagging you because you help me the last time

aleleba avatar Sep 17 '25 18:09 aleleba

Also I see on terminal docs that there is a access-token and a refresh-token, is possible to create it and be able to create a headless auth like that?

code tunnel user login --help
Log in to port forwarding service

Usage: code-tunnel tunnel user login [OPTIONS]

Options:
      --access-token <ACCESS_TOKEN>    An access token to store for authentication [env: VSCODE_CLI_ACCESS_TOKEN=]
      --refresh-token <REFRESH_TOKEN>  An access token to store for authentication [env: VSCODE_CLI_REFRESH_TOKEN=]
      --provider <PROVIDER>            The auth provider to use. If not provided, a prompt will be shown [possible values: microsoft, github]
  -h, --help                           Print help

GLOBAL OPTIONS:
      --cli-data-dir <CLI_DATA_DIR>  Directory where CLI metadata should be stored [env: VSCODE_CLI_DATA_DIR=]
      --verbose                      Print verbose output (implies --wait)
      --log <level>                  Log level to use [possible values: trace, debug, info, warn, error, critical, off]

can you give me more docs and insight where I can found this or generate it to get this fixed. I do not want to restart the auth process every 24 hours.

aleleba avatar Sep 17 '25 21:09 aleleba

sorry for be so pushing on this @connor4312 but is very urgent for me, as I said on Saturday I will give a talk on how to use VSCode tunnel, so is important to me if be fixed by that day.

aleleba avatar Sep 17 '25 21:09 aleleba

Github does not provide refresh tokens. They store their access tokens in an LRU and least recently used tokens will expire. The CLI pings Github every our to try to keep its access token recent but this is not a sure thing. There is not much we can do here.

connor4312 avatar Sep 17 '25 23:09 connor4312

Thank you @connor4312 for your fast response can you explain more in detail what is a LRU? I do not understand why it was working before, as I said before yesterday it was working without any issue from months.

aleleba avatar Sep 17 '25 23:09 aleleba

You are refering to Least Recently Used? this is a cache? I am trying to understand the authentication mechanism to be able to fix it, what we should do if I get this error? :

[2025-09-17 15:02:56] info error refreshing token: error requesting https://api.github.com/user: 401 {"message":"Bad credentials","documentation_url":"[https://docs.github.com/rest","status":"401"}](https://docs.github.com/rest%22,%22status%22:%22401%22%7D)

I do not understand why it does not authenticate if I have already authenticated, it should renew the refresh token right?

I am getting a 401 an unauthenticated error, but the tunnel was already authenticated before

aleleba avatar Sep 18 '25 00:09 aleleba

@connor4312 any update or recomendation?

aleleba avatar Sep 18 '25 19:09 aleleba

@connor4312 @bamurtaugh any update for this?, this is still happening.

aleleba avatar Sep 19 '25 01:09 aleleba

@connor4312 @bamurtaugh I found that there are some previous error

2025-09-19 02:10:23] info [tunnels::connections::ws] error reading websocket: WebSocket protocol error: Connection reset without closing the handshake

2025-09-19 02:10:23] warn The tunnel exited unexpectedly but gracefully, and reconnected.

And then I get: [2025-09-19 02:10:38] Information error while refreshing the token: Error requesting https://api.github.com/user: 401

aleleba avatar Sep 19 '25 03:09 aleleba

Hi @connor4312 @bamurtaugh I think this is related to this:

  • https://github.com/microsoft/vscode/issues/267122
  • https://github.com/microsoft/vscode/issues/267495
  • https://github.com/microsoft/vscode/issues/266544
  • https://github.com/microsoft/vscode/issues/265597

seems to be some error with token vscode authentication maybe, can we can following up of this?, Do you are able to reproduce it?,

Also seems to be that we carried this error seems like two weeks ago, I found reports of this issue, and I think this should be checked as priority since a dev tunnel environment that lost their credentials every day or less, is unuseful to work, as I said I have it running before without any issues for months.

To give some context because VSCode does not have an official Docker Image to run a VSCode Tunnel I create one by myself: https://github.com/aleleba/aleleba-vscode-dockerfile-configuration https://hub.docker.com/r/aleleba/vscode and It relies on the CLI and on VSCode, It was great to work from the tunnel and it is reproducible and reliable since I have all configs there, but because I use a lot of tools every time I need to restart I need an hour to create the whole environment, so I lose one hour every day.

I give some information that this issue does not happen only to me, and be very appreciated to get a fix or at least a response, again thanks for the help.

aleleba avatar Sep 22 '25 17:09 aleleba

Hi again @connor4312 and @bamurtaugh, sorry to bother you again, I only want a response something like, we are working for a workaround or something, thank you in advance.

aleleba avatar Sep 23 '25 18:09 aleleba

@connor4312 @bamurtaugh , sorry to be so pushing but I only want to make some following up to this issue, thank you in advance.

aleleba avatar Sep 26 '25 18:09 aleleba

I have the same problem and can not find the solution. Please fix it ASAP!

proroad97 avatar Oct 02 '25 08:10 proroad97