Search code examples

How to use Windows user credentials for proxy authentication in R/RStudio

To install packages in RStudio on my corporate network, I need to set system env variables for proxy authentication:

Sys.setenv(https_proxy_user = "userid:password")
Sys.setenv(https_proxy = "proxy.<my.domain>:8080")

This works, but has the disadvantage of exposing my Windows userid:password in full clear text in an R script or in my .RProfile.

Also, if I change my Windows login, I have to adjust the script.

Is it possible to tell RStudio/R to use my Windows credentials directly for proxy authentication, like for example this can be done in C#?


Using keyring to store encrypted credentials doesn't seem to be an option as I would need to update these credentials manually each time I change my Windows user password.

[EDIT] As no solution was found yet, I opened an RStudio enhancement request


  • After opening an RStudio enhancement request, I got following answer from @kevinushey :

    It's unfortunately deprecated, but you might have better luck using options(download.file.method = "wininet") on Windows.

    Turns out this still works with R 4.3.1 and R 4.3.2 under Windows and is exactly what I was looking for :

    options(download.file.method = "wininet")

    Allowed me under RStudio to use package update / install menu without specifying https_proxy and without exposing my Windows user credentials.

    [EDIT] As wininet is now superseded and might disappear in coming R versions, final solution with default curl method is (again credit @kevinushey):

    Sys.setenv(https_proxy_user = ":")
    Sys.setenv(https_proxy = 'proxy.<my.domain>:proxyport')