Last active
October 22, 2020 17:07
-
-
Save cderv/35b49bbe05ea6d93a2b8f2a4fe61d4b4 to your computer and use it in GitHub Desktop.
Proxy Configuration
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
# 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