Background: We have a shiny app deployed on our Connect server. Within this app, there is a button that you can click to create a pinned dataset on the Connect pin board. We want the pin owner to be the current user; however, the pin owner is assigned to the user who deployed the shiny app.
Question: How can we setup board_connect()
and pin_write()
so that the owner is assigned to the current user (i.e., session$user
)?
What we tried: We have attempted to assign ownership to the current app user in two ways, both neither seem to have any impact on the owner of the created pin:
- Set
account = session$user
in theboard_connect()
function - Set the user ownership at the pin level using
owner/pin
syntax when naming pins (e.g., 'anthonypileggi/pin1234')
Reprex: (for Connect-deployed shiny app )
library(shiny)
library(pins)
ui <- fluidPage(
actionButton("create", "Create Pin")
)
server <- function(input, output, session) {
observeEvent(input$create, {
board <-
pins::board_connect(
auth = "manual",
server = Sys.getenv("CONNECT_SERVER"),
key = Sys.getenv("CONNECT_API_KEY"),
account = session$user
)
#board <- pins::board_local()
pin_name <- paste0("pin", paste(sample(0:9, 4, replace = TRUE), collapse = ""))
file.path(session$user, pin_name)
board |> pins::pin_write(mtcars, name = pin_name, type = "rds")
showModal(modalDialog(
title = paste(pin_name, "created"),
"Check Connect to see who the pin's owner is",
easyClose = TRUE,
footer = NULL
))
})
}
shinyApp(ui, server)