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

Allow uid to be specified when using authenticator="externalbrowser" #817

Open
ray-pacheco opened this issue Jun 12, 2024 · 3 comments · May be fixed by #832
Open

Allow uid to be specified when using authenticator="externalbrowser" #817

ray-pacheco opened this issue Jun 12, 2024 · 3 comments · May be fixed by #832

Comments

@ray-pacheco
Copy link

ray-pacheco commented Jun 12, 2024

For our Snowflake instance we have external auth set up, but the connection string requires we pass our user name. Currently odbc::snowflake() does not allow you to pass uid without also providing pwd. Not sure if our setup is common, but I would like to be able to pass the uid when authenticator is specified without requiring pwd be specified as well.

# specifying authenticator as externalbrowser as is in the documentation example gives error requiring uid specified
con <- DBI::dbConnect(odbc::snowflake(),
                      account = "testorg-test_account",
                      authenticator = "externalbrowser")
#> Error in `DBI::dbConnect()`:
#> ! ODBC failed with error 28000 from [Snowflake][DSI].
#> ✖  (20032) Required setting 'UID' is not present in the connection settings.
#> ℹ From 'nanodbc/nanodbc.cpp:1150'.
#> Backtrace:
#>      ▆
#>   1. ├─DBI::dbConnect(...)
#>   2. ├─DBI::dbConnect(...)
#>   3. │ └─odbc (local) .local(drv, ...)
#>   4. │   ├─rlang::inject(dbConnect(odbc(), !!!args))
#>   5. │   ├─DBI::dbConnect(...)
#>   6. │   └─odbc::dbConnect(...)
#>   7. │     └─odbc (local) .local(drv, ...)
#>   8. │       └─odbc:::OdbcConnection(...)
#>   9. │         ├─base::withCallingHandlers(...)
#>  10. │         └─odbc:::odbc_connect(...)
#>  11. └─odbc (local) `<fn>`("nanodbc/nanodbc.cpp:1150: 28000\n[Snowflake][DSI] (20032) Required setting 'UID' is not present in the connection settings. ")
#>  12.   └─cli::cli_abort(...)
#>  13.     └─rlang::abort(...)

# specifying uid and authenticator as externalbrowser  gives error requiring pwd specified
con <- DBI::dbConnect(odbc::snowflake(),
                      account = "testorg-test_account",
                      uid = "[email protected]",
                      authenticator = "externalbrowser")
#> Error in `DBI::dbConnect()`:
#> ! Both `uid` and `pwd` must be specified to authenticate.
#> ℹ Or leave both unset to use ambient Snowflake credentials.
#> Backtrace:
#>     ▆
#>  1. ├─DBI::dbConnect(...)
#>  2. └─DBI::dbConnect(...)
#>  3.   └─odbc (local) .local(drv, ...)
#>  4.     └─odbc:::snowflake_args(...)
#>  5.       └─odbc:::snowflake_auth_args(account, ...)
#>  6.         └─rlang::abort(...)
#>  

# I am able to get around this today by sending a blank password, but this probably is not ideal
con <- DBI::dbConnect(odbc::snowflake(),
                      account = "testorg-test_account",
                      uid = "[email protected]",
                      pwd = "",
                      authenticator = "externalbrowser")
@hadley
Copy link
Member

hadley commented Jun 13, 2024

cc @atheriel

@atheriel
Copy link
Collaborator

Yeah this makes perfect sense, we should update the check to allow externalbrowser as well.

@simonpcouch
Copy link
Collaborator

Had a slightly different experience with this today--when connecting, I saw:

con <- dbConnect(snowflake(), authenticator = "externalbrowser")
#> Error in `dbConnect()`:
#> ! ODBC failed with error 00000 from [Snowflake][DSI].
#> ✖  (20032) Required setting 'UID' is not present in the connection settings.

So I set:

con <- dbConnect(snowflake(), authenticator = "externalbrowser", UID = "[email protected]")

...and the connection worked fine. I didn't look at the snowflake() docs, but if I had, I would have seen that the case is uid in dbConnect(snowflake()) and passed the argument with that case:

con <- dbConnect(snowflake(), authenticator = "externalbrowser", uid = "[email protected]")
#> Error in `DBI::dbConnect()`:
#> ! Both `uid` and `pwd` must be specified to authenticate.
#> ℹ Or leave both unset to use ambient Snowflake credentials.

So, for now, another workaround is to change the case of uid, but this is another place of being bit by the case-insensitivity of argument keys in ODBC.

All that said, this is worth fixing. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants