Secrets is a library for interfacing secrets set in the Robocloud Vault (used by default) or file-based secrets, which can be taken into use by setting two environment variables below.

Robocloud Vault works together with Robocloud Worker or Robocode CLI. Following three environment variables need to exist (these are set by Robocloud Worker automatically and can be set manually with Robocode CLI).

  • RC_API_SECRET_HOST : URL to Robocloud Secrets API
  • RC_API_SECRET_TOKEN : API Token for Robocloud Secrets API
  • RC_WORKSPACE_ID : Robocloud Workspace ID

File based secrets can be set by defining two environment variables.

  • RPA_SECRET_MANAGER : 'RPA.Robocloud.Secrets.FileSecrets'
  • RPA_SECRET_FILE : Absolute path to the secrets JSON file.
{
    "swaglabs": {
        "username": "standard_user",
        "password": "secret_sauce"
    }
}

Examples

Robot Framework

*** Settings ***
Library    Collections
Library    RPA.Robocloud.Secrets

*** Tasks ***
Reading secrets
    ${secret}=    Get Secret  swaglabs
    Log Many      ${secret}

Modifying secrets
    ${secret}=          Get Secret      swaglabs
    ${level}=           Set Log Level   NONE
    Set To Dictionary   ${secret}       username    nobody
    Set Log Level       ${level}
    Set Secret          ${secret}

Python

from RPA.Robocloud.Secrets import Secrets

SECRETS = Secrets()


def reading_secrets():
    print(f"My secrets: {SECRETS.get_secret('swaglabs')}")


def modifying_secrets():
    secret = SECRETS.get_secret("swaglabs")
    secret["username"] = "nobody"
    secrets.set_secret(secret)