You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "thomasaarholt (via GitHub)" <gi...@apache.org> on 2023/07/20 12:23:27 UTC

[GitHub] [arrow-adbc] thomasaarholt opened a new issue, #918: [snowflake] MFA token not being cached?

thomasaarholt opened a new issue, #918:
URL: https://github.com/apache/arrow-adbc/issues/918

   Hello! Thank you very much for adding Snowflake support to arrow-adbc!
   
   I'm running arrow-adbc in Python 3.11 on macOS.
   
   I've got the connection working as follows, but I have to accept multi-factor-authentication (MFA) each time I make a request (even within the same python session), despite the [documentation stating that `cache_mfa_token` is true on MacOS](https://arrow.apache.org/adbc/0.5.0/driver/snowflake.html#client-options) (search for `adbc.snowflake.sql.client_option.cache_mfa_token`):
   ```python
   from adbc_driver_snowflake import dbapi
   user = password = account = database = schema = warehouse = role = "..."
   
   uri = f"{user}:{password}@{account}/{database}/{schema}?warehouse={warehouse}&role={role}"
   query = "select * from my_table limit 10"
   
   with dbapi.connect(uri=uri) as conn:
       cursor = conn.cursor()
       cursor.execute(query)
       tbl = cursor.fetch_arrow_table()
       cursor.close()
   
   print(tbl)
   ```
   
   I've also tried passing `db_kwargs={"cache_mfa_token":"true"}` to `connect`, without success. 
   
   Does anyone have any ideas? I would quite like to replace usage of snowflake-connector-python with adbc, but it's a major hassle to accept MFA on each request.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-adbc] zeroshade commented on issue #918: [snowflake] MFA token not being cached?

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on issue #918:
URL: https://github.com/apache/arrow-adbc/issues/918#issuecomment-1652284783

   Hmm, just to confirm: @thomasaarholt are you setting `"adbc.snowflake.sql.auth_type": "auth_mfa"` in the `db_kwargs`? Looking at the underlying snowflake code, it looks like it will only cache the mfa token is the auth type is set appropriately.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-adbc] lidavidm commented on issue #918: [snowflake] MFA token not being cached?

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on issue #918:
URL: https://github.com/apache/arrow-adbc/issues/918#issuecomment-1643854135

   @zeroshade any idea?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [snowflake] MFA token not being cached? [arrow-adbc]

Posted by "thomasaarholt (via GitHub)" <gi...@apache.org>.
thomasaarholt commented on issue #918:
URL: https://github.com/apache/arrow-adbc/issues/918#issuecomment-1795005777

   In my previous post I had written `"cache_mfa_token": "true", # this one is unnecessary on Mac`. That was complete nonsense 😅 .
   
   Closing this with a final, working code example, using a double context manager to close the connection and cursor.
   
   ```python
   with dbapi.connect(
       uri=uri,
       db_kwargs={
           "adbc.snowflake.sql.client_option.cache_mfa_token": "true",
           "adbc.snowflake.sql.auth_type": "auth_mfa",
       },
   ) as conn:
       with conn.cursor() as cursor:
           cursor.execute(query)
           tbl = cursor.fetch_arrow_table()
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [snowflake] MFA token not being cached? [arrow-adbc]

Posted by "thomasaarholt (via GitHub)" <gi...@apache.org>.
thomasaarholt closed issue #918: [snowflake] MFA token not being cached?
URL: https://github.com/apache/arrow-adbc/issues/918


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-adbc] thomasaarholt commented on issue #918: [snowflake] MFA token not being cached?

Posted by "thomasaarholt (via GitHub)" <gi...@apache.org>.
thomasaarholt commented on issue #918:
URL: https://github.com/apache/arrow-adbc/issues/918#issuecomment-1653170247

   Ah! I did not, and now it works! I had the following code (without the new, commented line):
   ```python
   with dbapi.connect(
       uri=uri,
       db_kwargs={
           "cache_mfa_token": "true", # this one is unnecessary on Mac
           # "adbc.snowflake.sql.auth_type": "auth_mfa",
       },
   ) as conn:
       cursor = conn.cursor()
       cursor.execute(query)
       tbl = cursor.fetch_arrow_table()
       cursor.close()
   ```
   But I hadn't thought to set that one, since I was already getting MFA authentications on my phone!
   
   This works great, thank you! But perhaps we can add to the docs that in order to cache MFA tokens, then ` "adbc.snowflake.sql.auth_type": "auth_mfa"` has to be explicitly passed to `db_kwargs`?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org