OAUTH authentication possibilities for Python library
Hi,
We have an internal library that queries Snowflake. On Jupyter lab, users are authenticated using external browser. Is this possible on Dataiku?
If not possible, is there a way for our Python code library to pass the username to the Dataiku Snowflake connection and get back an access token to run queries?
Can we access the python Snowflake connection object used by SQLExecutor2 and retrieve an access token?
thx
Operating system used: Windows 10
Answers
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,088 Neuron
I am a bit confused, are you already using Snowflake with OAuth2 in Dataiku?
https://doc.dataiku.com/dss/latest/connecting/sql/snowflake.html#authenticate-using-oauth2
If so is your requirement that your internal Python library to handle the OAuth2 authentication on behalf of the user?
-
We are when creating datasets. We also have SQL we need to execute that has nothing to do with creating datasets. I just found out I may be able to use the SqlExecutor2 to execute the SQL using this pattern:
dku_connector = SqlExecutor2(connection=MY_SNOWFLAKE_CONNECTION) dku_connector.query_to_df(sql_str, post_queries=['COMMIT'])
If this doesn't work, the idea was we could pass the user Snowflake token from Dataiku to our Python library to execute this type of SQL.
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,088 Neuron
You can certainly execute queries like that but I am not sure if you can pass the user ID. It's certainly possible to pass the Role and DWH though, see this thread which is asking for the same thing:
Personally I would have users using the SQL Notebooks (not Python Notebook) with a connection with per-user credentials.
-
@Turribeach
Thanks much for the link, will check it out. We weren't using notebooks, rather regular Python recipes where we ran into this corner case issue.