snowflakedb / snowflake-connector-python

Snowflake Connector for Python
https://pypi.python.org/pypi/snowflake-connector-python/
Apache License 2.0
568 stars 456 forks source link

SNOW-1473577: MFA caching not working when set internal_application_name or internal_application_version #1972

Open sfc-gh-astus opened 3 weeks ago

sfc-gh-astus commented 3 weeks ago

Python version

Python 3.12.3 (main, Apr 9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)]

Operating system and processor architecture

macOS-14.5-arm64-arm-64bit

Installed packages

annotated-types==0.7.0
asn1crypto==1.5.1
certifi==2024.6.2
cffi==1.16.0
cfgv==3.4.0
charset-normalizer==3.3.2
click==8.1.7
coverage==7.5.2
cryptography==42.0.8
distlib==0.3.8
filelock==3.14.0
gitdb==4.0.11
GitPython==3.1.43
identify==2.5.36
idna==3.7
iniconfig==2.0.0
jaraco.classes==3.4.0
Jinja2==3.1.4
keyring==24.3.1
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
more-itertools==10.2.0
nodeenv==1.9.1
override-build-in-commands
packaging==24.0
platformdirs==4.2.2
pluggy==1.5.0
pre-commit==3.7.1
pycparser==2.22
pydantic==2.7.1
pydantic_core==2.18.2
pydevd-pycharm==241.17011.127
Pygments==2.18.0
PyJWT==2.8.0
pyOpenSSL==24.1.0
pytest==8.2.1
pytest-randomly==3.15.0
pytz==2024.1
PyYAML==6.0.1
requests==2.32.2
requirements-parser==0.9.0
rich==13.7.1
setuptools==69.5.1
shellingham==1.5.4
smmap==5.0.1
snowflake-connector-python==3.10.1
sortedcontainers==2.4.0
syrupy==4.6.1
tomlkit==0.12.5
typer==0.12.3
types-setuptools==70.0.0.20240524
typing_extensions==4.12.1
urllib3==2.2.1
virtualenv==20.26.2

What did you do?

MFA caching works for this case

with snowflake.connector.connect(
        application="MFA.TEST",
        client_request_mfa_token=True,
        authenticator="username_password_mfa",
        user="astus",
        password="...",
        account="...",
        host="...",
        database="astus_db",
        schema="public",
        warehouse="xsmall",
        application_name="snowcli",
        # internal_application_name="snowcli",
        # internal_application_version="2.5.0.dev0",
) as conn:
    with conn.cursor() as cur:
        cur.execute(f"select 1")
        print(cur.fetchall())

But when pass internal_application_name or internal_application_version it stops.


### What did you expect to see?

MFA caching should work with `internal_application_name` and `internal_application_version` values passed.

### Can you set logging to DEBUG and collect the logs?

```bash
import logging
import os

for logger_name in ('snowflake.connector',):
    logger = logging.getLogger(logger_name)
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))
    logger.addHandler(ch)
sfc-gh-dszmolka commented 3 weeks ago

(handling internally for now)