简体   繁体   中英

Snowflake auth issues using AWS SageMaker notebooks

We're using Python 3.x locally to connect to Snowflake, using the "externalbrowser" authentication method. This works quite nicely running code locally, where it automatically opens another browser tab and finishes authenticating that way.

from sqlalchemy import create_engine
from snowflake.sqlalchemy import URL

engine = create_engine(URL(
account="MY_ACCOUNT",
user="MY_USERNAME",
authenticator="externalbrowser",
role="MY_ROLE",
warehouse="MY_WAREHOUSE"
))
connection = engine.connect()

However running the same code from within an AWS SageMaker (Juypter) notebooks throws an error since it has no browser tab to open to complete the authentication. The error being returned is,

DatabaseError: (snowflake.connector.errors.DatabaseError) 250008 (08001): Failed to connect to DB: <MY_ACCOUNT>.snowflakecomputing.com:443, Unable to open a browser in this environment.
(Background on this error at: https://sqlalche.me/e/14/4xp6)

We don't have any Okta authentication enabled or any other SAML (or OAuth) authentication options we can use instead. Is there any other way around this issue with SageMaker notebooks and externalbrowser authentication?

SSO wont work from sagemaker notebooks with externalbrowser option. Instead of this, you may use one of the following options for authentication:

  1. Username/Password - store the creds in secrets manager or ssm

  2. Kpaitey auth - Assign the user the public key and use that to authenticate.

3.Run a local jupyter notebook but use boto3 to manage AWS assets (less secure depending on the environment setup)

  1. External OAuth - Closest to being a pure SSO solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM