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

Soda Test Snowflake add oauth #556

Open
janhelmu opened this issue Dec 17, 2024 · 5 comments
Open

Soda Test Snowflake add oauth #556

janhelmu opened this issue Dec 17, 2024 · 5 comments

Comments

@janhelmu
Copy link

Hello datacontract-team,

please can you add oauth login for snowflake?

sf = snowflake.connector.connect(
account=os.getenv("SNOWFLAKE_ACCOUNT"),
user= snf_user + "XXX",
password="",
role=os.getenv("SNOWFLAKE_ROLE"),
warehouse=os.getenv("SNOWFLAKE_WAREHOUSE"),
database=sf_db,
authenticator="oauth",
token= token
)

Thanks for your support.

best regards

Jan

@jochenchrist
Copy link
Contributor

OK, this should be doable, as it is supported in soda-core-snowflake: https://github.com/sodadata/soda-core/blob/main/soda/snowflake/soda/data_sources/snowflake_data_source.py#L80

@janhelmu
Copy link
Author

Hi Jochen thanks for your support. Yes I see it will be supported by soda.
Do you know how can I implemented with your package? I mean I use following in a yml file.

datacontracts:
variables:
DATACONTRACT_SNOWFLAKE_USERNAME: ${SNF_USER}
DATACONTRACT_SNOWFLAKE_PASSWORD: ${SNF_PASSWORD_LOCAL}
DATACONTRACT_SNOWFLAKE_WAREHOUSE: ${SNF_WAREHOUSE}
DATACONTRACT_SNOWFLAKE_ROLE: ${SNF_ROLE}

Thanks again for your help.

Jan

@jochenchrist
Copy link
Contributor

Try to also set these ENV parameters to use oauth:

DATACONTRACT_SNOWFLAKE_AUTHENTICATOR=oauth
DATACONTRACT_SNOWFLAKE_TOKEN=your-token

@janhelmu
Copy link
Author

Hi Jochen,

thanks for your quick response but it does not work.

datacontracts:
variables:
DATACONTRACT_SNOWFLAKE_USERNAME: ${SNF_USER}
DATACONTRACT_SNOWFLAKE_PASSWORD: ${SNF_PASSWORD_LOCAL}
DATACONTRACT_SNOWFLAKE_WAREHOUSE: ${SNF_WAREHOUSE}
DATACONTRACT_SNOWFLAKE_ROLE: ${SNF_ROLE}
DATACONTRACT_SNOWFLAKE_AUTHENTICATOR: "oauth"
DATACONTRACT_SNOWFLAKE_TOKEN: "eyJhbGcxxxxxxxxxxxxxxx"

I getting the following error message.

ERROR:soda.scan:[18:05:32] Could not connect to data source "snowflake": 250001 (08001): Failed to connect to DB: xxxx.eu-central-1.snowflakecomputing.com:443. Invalid OAuth access token.

Thanks and I wish you a great weekend.

@jochenchrist
Copy link
Contributor

Hi @janhelmu,

your env variables

I double-checked that the authenticator and token would be passed to the soda-core configuration (https://docs.soda.io/soda/connect-snowflake.html) and https://docs.snowflake.com/developer-guide/python-connector/python-connector-api#connect.

data_source snowflake:
  account: my-account
  authenticator: oauth
  connection_timeout: '5'
  database: my_database
  password: pw
  role: role
  schema: my_schema
  token: eyJhbGcxxxxxxxxxxxxxxx
  type: snowflake
  username: myuser
  warehouse: mywarehouse

I am not familiar with Snowflake's OAuth authentication, but from a configuration perspective the values are set.

Could you check again that the token is valid for this role?

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

2 participants