0
votes

I am connecting to Snowflake using PyCharm. I am successfully able to connect and run my SQL queries over but for each run, Pycharm opens the a new tab in my browser with this message:

Initiating login request with your identity provider. A browser window should have opened for you to complete the login. If you can't see it, check existing browser windows, or your OS settings. Press CTRL+C to abort and try again...

Anyone has suggestion how to stop opening browser window every time for each request and keep the session alive?

2

2 Answers

0
votes

You have a few options:

  • Continue using externalbrowser, this always requires a browser to authenticate. However, you can cache the result token so that it doesn't always spawn a browser:

    • Change your account to allow_id_token:

use role accountadmin; alter account set allow_id_token = true;

  • Then make sure you are on Snowflake python connector 2.2.8 with keyring python module installed:

pip install --upgrade snowflake-connector-python==2.2.8 pip install keyring

  • The next option only works if you have okta, but if you do, you can use, then no browser required. This DOES NOT WORK with MFA.

authenticator=https://<okta_account>.okta.com/

  • You can use key pair authentication instead.

https://docs.snowflake.com/en/user-guide/python-connector-example.html#using-key-pair-authentication

  • You can use external oauth, but this requires setup in your IDP:

https://docs.snowflake.com/en/user-guide/oauth-external.html

Hope these help!

0
votes

It looks like you are using an IDP and SSO for connecting to snowflake. Can you share your connection parameters. Ideally through programs, you should use private key to connect to SNOWflake using a service account

https://github.com/Infosys/Snowflake-Python-Development-Framework

In the above repository, you will see a function that tells you how to connect using private key