Using Keyring


Note: This feature is currently available only in the RStudio 1.2 Preview.

Keyring is a platform-independent API to access the operating systems credential store. From RStudio 1.2 (currently only available in daily builds), you can use keyring to store secrets using `.rs.askForSecret()` R function.

Keyring currently supports:

  • Keychain on macOS,
  • Credential Store on Windows,
  • the Secret Service API on Linux, and
  • environment variables on all platforms. Additional storage backends can be added easily.


OS X and Windows do not require additional software.

For Linux, install the libsecret library, at least version 0.16.

  • Debian/Ubuntu: libsecret-1-dev
  • Recent RedHat, Fedora and CentOS systems: libsecret-devel

Using Keyring

Keyring can be used to store secrets in RStudio using the rstudioapi::askForSecret() function. This is useful and recommended while storing sensitive information like connection passwords and connection strings.

One can retrieve and store a secret with:

secret <- rstudioapi::askForSecret("Test")


If the keyring package is not installed, the checkbox will be disabled. Keyring can be manually installed using installed.packages("keyring") or by clicking the keyring hyperlink in the dialog and following the installation prompt.

If the user checks the "Remeber using keyring?" checkbox, then subsequent calls to:

secret <-rstudioapi::askForSecret("Test")

will remember the previous value and also retrieve the secret contents.


To remove a previously stored value, one can uncheck the "Remeber using keyring?" checkbox.