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

Browser authentication token not being cached #49

Open
dlouseiro opened this issue Oct 23, 2024 · 2 comments
Open

Browser authentication token not being cached #49

dlouseiro opened this issue Oct 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@dlouseiro
Copy link
Contributor

When using the tap with use_browser_authentication=True, I noticed that the browser auth tokens are not being cached, even if one's Snowflake account has token caching enabled.

From my experience, this can be achieved by applying two simple changes:

  1. Use , extras = ["secure-local-storage"] when declaring the snowflake-connector-python as a project dependency (pyproject.toml)
  2. Pass client_store_temporary_credential in connection arguments (mostly important for linux users, as documented here):
# Enable temporary credential file for Linux users
# For Linux users, since there are no OS-key-store, an unsecure temporary credential for SSO can be enabled by this option. The default value for this option is False.
# client_store_temporary_credential = True
@edgarrmondragon edgarrmondragon added the bug Something isn't working label Oct 23, 2024
@edgarrmondragon
Copy link
Member

PRs welcome!

@dlouseiro
Copy link
Contributor Author

PRs welcome!

Here you go @edgarrmondragon!

edgarrmondragon pushed a commit that referenced this issue Oct 25, 2024
…sic authentication with MFA (#50)

The purpose of this PR is to fix the issue reported
[here](#49),
essentially making sure that oauth tokens are cached when using browser
authentication to avoid having multiple browser windows popping in
consecutive runs, even when the Snowflake account being accessed has
[ALLOW_ID_TOKEN](https://docs.snowflake.com/en/sql-reference/parameters#allow-id-token)
option enabled.

While there, also ensured proper caching of MFA tokens (when the user
account has
[ALLOW_CLIENT_MFA_CACHING](https://docs.snowflake.com/en/sql-reference/parameters#allow-client-mfa-caching)
enabled).

### Implementation details:
- Add `secure-local-storage` extra to `snowflake-connector-python`
dependency
- Add `"client_request_mfa_token": True` and
`"client_store_temporary_credential": True` to the connection arguments
of the SQLAlchemy engine. This is mostly relevant for Linux users, as
for MacOs (at least) the `secure-local-storage` extra is enough.
- Fix some linting issues (done by `pre-commit` steps)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants