I’m a fan and advocate of using Visual Studio Code devcontainers however I’ve hit a snag when using them.
Our organisation uses a service called Snowflake (its a cloud-based analytical DB, not that that’s important). They have a command-line tool called snowsql
that is used to interact with the service and in order to use snowsql
one must first authenticate. The easiest way to do that is to use browser authentication whereby a browser is opened to allow me to enter my credentials and then a token is passed back to snowsql
.
The command to authenticate is snowsql -a <accountID> -u [email protected] --authenticator externalbrowser
which launches the browser window. I enter my credentials and them am redirected back to http://localhost:<port>/?token=<token>. The problem is that <port> is not open on the devcontainer and its a different port every time. Hence I have to setup port forwarding (as described at https://code.visualstudio.com/docs/editor/port-forwarding). After I have forwarded the port specified in the URL then I hit refresh in my browser and everything works fine – the token is returned to snowsql
and I can carry on with my work.
Its annoying to have to do this every single time though, and in some circumstances I need to do this many many times a day.
I’m vaguely aware that its possible for VS Code to detect processes are listening on a port (useful information at https://github.com/microsoft/vscode/issues/143958) however this doesn’t seem to be working in my case.
Can anyone suggest why a port is not being forwarded for snowsql
?