Skip to content

Instantly share code, notes, and snippets.

@slopp
Created August 1, 2018 14:39
Show Gist options
  • Select an option

  • Save slopp/a0315e195139672be90b7af46527066c to your computer and use it in GitHub Desktop.

Select an option

Save slopp/a0315e195139672be90b7af46527066c to your computer and use it in GitHub Desktop.
Example of adding a cookie to the cookie store during programmatic deployment
# This code adds a cookie to all requests to a server
cookieFile <- 'cookie'
connectHost <- 'colorado.rstudio.com'
connectPort <- '3939'
connectProtocolPrefix <- 'http://'
# Start by adding a server
rsconnect::addServer(
url = paste0(connectProtocolPrefix, connectHost, ':', connectPort)
name = connectHost
)
# now add a cookie store to this server
requestURL <- list(
host = connectHost,
port = connectPort
path = "/"
)
cookie <- readChar(cookieFile, file.info(cookieFile)$size)
rsconnect:::storeCookies(requestURL, list(cookie))
# To view cookie store rsconnect:::.cookieStore$`colorado.rstudio.com:3939`
# Add the user with verbose logging to check the http request for the cookie
options(rsconnect.http.verbose = TRUE)
rsconnect::connectUser('sean', 'colorado.rstudio.com')
# Deploy content
rsconnect::deployApp(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment