Created
August 1, 2018 14:39
-
-
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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