Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowflake Driver for SQL tools #56

Open
praneeth1987 opened this issue Sep 13, 2022 · 6 comments
Open

Snowflake Driver for SQL tools #56

praneeth1987 opened this issue Sep 13, 2022 · 6 comments

Comments

@praneeth1987
Copy link

I have installed this driver and using this in VS Code, But just want to know in which it was developed? .NET or node.js

@koszti
Copy link
Collaborator

koszti commented Sep 13, 2022

nodejs

@praneeth1987
Copy link
Author

Thanks. Post SSO authentication in browser, I am getting below webpage pointing to local host? Is this expected and if so, how to avoid this?

Note: Authentication is working as expected just curious about the screenshot provided below

VSS Driver

@xendren
Copy link

xendren commented Sep 20, 2022

We are getting the same thing. We are using the extension on a remote server using the VS Code remote SSH extension. It appears that the port for localhost is not able to return the snowflake token back to the external server. Just a guess.

@xendren
Copy link

xendren commented Sep 20, 2022

The problem appears to be that the port the extension is using to open the external browser is different each time you attempt to connect, and the extension is not configuring the port as a "Forward Port" in VS Code. Once the browser hits Snowflake and logs the user in, it is attempting to send the token to localhost on the port, but it isn't being tunneled back to the remote server.

We are also using the dbt vs code extension. By calling "dbt debug", it does the same thing through the Snowflake driver and opens the external browser. Once we authenticate, it tries to return the token, but gets the same error. We were able to copy the port from the external browser, switch over to VS Code on the "Port Forwarding" tab in the terminal, click "Add Port" and paste that port number. Go back to the external browser and click the refresh button to make it try again, and it successfully captures the token since the dbt debug command is still actively listening in the terminal. We were not able to get that workaround to work when configuring a SQL Tools connection to snowflake, however.

@koszti
Copy link
Collaborator

koszti commented Sep 21, 2022

@xendren I think your explanation makes sense.

The browser based authentication logic is implemented by the auth_web.js in the official upstream Snowflake node.js driver. It's creating a temporary "HTTP-like" server on localhost using a random port where the browser will be redirected after a successful authentication.

I think the reason why the dbt vscode extension works differently is the fact that the dbt extension is not not connecting directly to snowflake but it's using the dbt CLI under the hood. The dbt CLI is written in python, and using the more advanced python snowflake connector. I assume the python snowflake driver is implemented slightly differently than the node.js driver or it behaves differently as you're connecting to snowflake out of vs code. I haven't checked it in details though.

Just to confirm, do I understand correctly that the browser based authentication basically works, the token is somehow received via the generated URL and able to connect to snowflake? Even if the success confirmation message is not displayed in the browser. @praneeth1987 is this what you can see?

@xendren
Copy link

xendren commented Sep 29, 2022

@xendren I think your explanation makes sense.

The browser based authentication logic is implemented by the auth_web.js in the official upstream Snowflake node.js driver. It's creating a temporary "HTTP-like" server on localhost using a random port where the browser will be redirected after a successful authentication.

I think the reason why the dbt vscode extension works differently is the fact that the dbt extension is not not connecting directly to snowflake but it's using the dbt CLI under the hood. The dbt CLI is written in python, and using the more advanced python snowflake connector. I assume the python snowflake driver is implemented slightly differently than the node.js driver or it behaves differently as you're connecting to snowflake out of vs code. I haven't checked it in details though.

Just to confirm, do I understand correctly that the browser based authentication basically works, the token is somehow received via the generated URL and able to connect to snowflake? Even if the success confirmation message is not displayed in the browser. @praneeth1987 is this what you can see?

Not sure if this was directed at me, but yes it will work, but the user has to determine the random port from the URL and then manually add the Port forwarding in VS Code for that port to get it to work. Every day when they reconnect to the remote server, they have to do this process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants