Skip to content

Conversation

@detule
Copy link
Owner

@detule detule commented Oct 30, 2024

No description provided.

simonpcouch and others added 13 commits September 3, 2024 16:47
* re`document()`
* address `cli_warn()` global variables NOTE
* remove `@inheritParams` that brought in problematic \usage
* netezzaSQL: customize odbcDataType

* add missing file

* NEWS: update
* dbConnect: clean up argument checks

* timeout: document NA to mean no timeout

* Update R/dbi-driver.R

Co-authored-by: Simon P. Couch <[email protected]>

* update docs

---------

Co-authored-by: Simon P. Couch <[email protected]>
* netezza: boolean column handling

* try dev dbitest

* Update NEWS.md

Co-authored-by: Simon P. Couch <[email protected]>

---------

Co-authored-by: Simon P. Couch <[email protected]>
…bi#853)

This commit expands the `databricks()` and `snowflake()` helpers to
support the viewer-based OAuth credentials recently introduced in Posit
Connect [0].

It is designed to support writing Shiny apps that take the following
form:

```r
library(shiny)

ui <- fluidPage(textOutput("user"))

server <- function(input, output, session) {
  conn <- reactive({
    pool::dbPool(odbc::snowflake(), session = session)
  })

  output$user <- renderText({
    res <- DBI::dbGetQuery(conn(), "SELECT CURRENT_USER()")
    res[[1]]
  })
}

shinyApp(ui = ui, server = server)
```

Checks for viewer-based credentials are designed to fall back gracefully
to existing authentication methods in some cases. This is intended to
allow users to -- for example -- develop and test a Shiny app that uses
Databricks or Snowflake credentials in desktop RStudio or Posit
Workbench and deploy it with no code changes to Connect.

In addition, making the caller pass a `session` argument (rather than
just detecting, for example, if we're in a Shiny server context) is very
intentional: it makes them express that they *want* viewer-based
credentials, as opposed to using shared credentials for all viewers. It
seems likely to reduce the number of cases where publisher credentials
are used unexpectedly.

Internally we implement the raw HTTP calls to make the token exchange
with Connect to avoid taking a dependency on the `connectapi` package.

Unit tests are included for most of the new error paths, but it's pretty
hard to emulate what Connect is doing here without extensive mocking.

[0]: https://docs.posit.co/connect/user/oauth-integrations/

Signed-off-by: Aaron Jacobs <[email protected]>
* src/: encoder is allocated once-per-connection

* encoding: Make column name encoding independent of column data encoding

* tests: use local_reproducible_output to skip unicode on Windows

* tests: code-review and another attempt at fixing Windows

* code-review: rename and reposition argument

* code-review: disallow NULL for name_encoding

* Add NEWS item
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 this pull request may close these issues.

5 participants