Skip to content

Instantly share code, notes, and snippets.

@cderv
Last active October 22, 2020 17:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cderv/35b49bbe05ea6d93a2b8f2a4fe61d4b4 to your computer and use it in GitHub Desktop.
Save cderv/35b49bbe05ea6d93a2b8f2a4fe61d4b4 to your computer and use it in GitHub Desktop.
Proxy Configuration
# Read a pasword using a prompt
read_Password <- function(prompt) {
if (requireNamespace("rstudioapi")) {
pwd <- rstudioapi::askForPassword(prompt)
} else if (exists(".rs.askForPassword")) {
pwd <- .rs.askForPassword(prompt)
} else {
pwd <- readline(prompt)
}
return (pwd)
}
# set proxy configuration for httr functions
set_config_proxy <- function(url, port, username, password = NULL, verbose = F){
if (is.null(password)) {
password <- read_Password("Enter a password for passing your proxy:")
} else {
if (verbose) {
message("Using provided password. Your password will seen in clear in your history command.")
}
}
httr::set_config(
httr::use_proxy(url = url,
port = port,
username = username,
password = password))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment