Datalore 2024.2 Help

Secrets

Use secrets to create sets of environment variables for your notebooks. Such variables can store passwords, API tokens, and other kinds of sensitive data for your notebooks to integrate with other services.

You can set up a secret for just one specific notebook or create a secret that you will be adding to more than one project.

As the creator of a secret, you are the sole user who can manage these variables. Editors can only view the values added to the secret. This can be very important when sharing a notebook.

Example: Using a secret to pass a GitHub token

In the example below, information about the notebook owner's GitHub account is requested using an API token.

r = requests.get('https://api.github.com/user', auth=('user_name', os.environ["github_token"]))

The token is passed in a secret with the github_token key. Users with edit permissions can use the code below to view the secured value :

print(os.environ["github_token"])

There are different ways of creating a secret and using it in one or several notebooks. Find more details in Create a secret and Manage secrets.

Last modified: 24 April 2024