OAUTH authentication possibilities for Python library

info-rchitect
Level 6
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

0 Kudos
4 Replies
Turribeach

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?

0 Kudos
info-rchitect
Level 6
Author

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.

 
0 Kudos

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:

https://community.dataiku.com/t5/Using-Dataiku/Global-environment-variables-set-dynamically-at-proje...

Personally I would have users using the SQL Notebooks (not Python Notebook) with a connection with per-user credentials.

0 Kudos
info-rchitect
Level 6
Author

@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.

0 Kudos