Search code examples
authenticationvscode-remotedev-tunnelsvscode-server

VSCode Server - devtunnel.ms - Access tunnel from Service / How to authenticate?


My Problem

I have multiple applications exposed via portforwarding on devtunnels through vscode server. I can access them perfectly fine, but one application needs to request another one, but it can't because its not authenticated (via github). So I dont know how to authenticate one application to access the devtunnels.ms website.

What I tried

I can access it from my browser (because I am authenticated). I tried to access on app from the other and its not working (I expected it to work, but I understand now why it doesnt work. But I dont get this problem solved alone...)

Longer and more detailed Text

Hello :)

I just setup a vscode server with the vscode cli tool via code tunnel. (https://code.visualstudio.com/docs/remote/tunnels) Everything is working fine, the ports are getting forwarded to https://<someid>-<port>.<region>.devtunnels.ms/ so I can access my Application from anywhere. On default those websites are secured, that you can only visit them when you are logged into github. My problem is now, that one Application should access content from the other Application - but it cannot access the app, because its not allowed (not logged into github). How can I allow my application to access my devtunnels.ms websites? On the following websites there are some informations about that topic, but not related to vscode server, instead to .NET and Visual Studio... Hope you understand - let me know if you need any more details or other description of the problem!

Thanks for your time and effort! Cheers!


Solution

  • You can get information from this article in the section "Access for web API clients". You need to install devtunnel cli and get a token for your tunnel.

    $ curl -sL https://aka.ms/DevTunnelCliInstall | bash
    $ source ~/.bashrc
    
    $ devtunnel user login -d -g # device login with github
    $ devtunnel list # get tunnels list
    $ devtunnel token <tunnel-id> --scopes connect # create token
    

    Next you should use header X-Tunnel-Authorization: tunnel TOKEN