How to assign pin ownership when creating pins in a Connect-deployed shiny app?

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:

  1. Set account = session$user in the board_connect() function
  2. 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)

Thanks for asking this, @anthonypileggi.

With Posit Connect, you can create a Visitor API Key integration on the Connect System Integration page . You can then associate that Visitor API Key with your Shiny app in the Access Settings of your content.

You can find more information in the Posit Connect Admin Guide.

If you have further questions, please contact our support team.

Hi David, thanks for the information - I'm the sysadmin working on this problem. I don't see a "Systems > Integrations" menu in Connect, either on the Connect menus, or on individual content menus. When I hit the API as directed in that document, I get a 404 error. Is this integrations feature available on version 2023.10.0?

Hi @EeethB, thanks for the follow-up. I should have mentioned in my reply that support for Visitor API Keys is available with the 2025.01.0 release. You'll find some info about this in the release notes.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.