Managing Secrets

If you have received or generated an access token in your workspace, you can use Secrets to manage your digital authentication credentials within the workspace.

Doing so will allow you to store tokens as environment variables. These can then be called up for use inside the workspace R console, Shiny Apps, and other built-in apps like Jupyter Notebook and RStudio.

Secret management is available to all roles within the workspace, except for the Contributor role.

Create a Secret

From the Administer dropdown menu, select Manage Secrets. This will open a new tab showing existing secrets and their creation date.

Manage Secrets.png

Selecting New secret will bring up a dialog box where you can enter the Secret name (this must be letters and numbers only) and the Value.

Add new secret.png

Once you have created your secret, it will appear in the list on the Secrets tab. Any secret can be deleted from this view as well, by clicking the appropriate selection box on the left and selecting Delete, or by clicking on the trashcan icon on the right side of the row. A prompt will ask you to confirm the deletion.

Accessing secrets as variables

Using R

Below you can see an example of a secret named “mynewsecret” being accessed within RStudio using the command:

Sys.getenv(“mynewsecret”)

This can be employed within the workspace R console, RStudio, and R Shiny apps.

Access Secret in RStudio.gif

You can see a video of this in action here.

Using Jupyter

If you are accessing your secret using Python within a Jupyter Notebook, the equivalent command is

import os
os.environ['mynewsecret']
Updated on February 22, 2024

Was this article helpful?