Registry / auth-security / robocorp-vault

robocorp-vault

JSON →
library1.4.1pypypi✓ verified 24d ago

Robocorp Vault is a Python library that provides an API for securely accessing secrets stored in the Robocorp Control Room Vault. It allows bots and assistants to retrieve sensitive information like usernames, passwords, and API keys. The library is part of the larger Robocorp ecosystem, offering a stable interface, with releases occurring as needed to support platform updates or introduce new features.

pip install robocorp-vault
INSTALL
IMPORT
SIG · ROBOCORP-VAULT
R
robocorp-vault
auth-securitypythonv1.4.1
Install
3.2s avg
Import
11ms
Disk
39MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.012s · 40.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.2s · import 0.010s · 42MB
39MB installed
● package 39MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_secret
from robocorp.vault import get_secret
from robocorp_vault import get_secret
The library's internal package name is `robocorp.vault`, not `robocorp_vault`.
SecretNotFound
from robocorp.vault import SecretNotFound
Import this exception to handle cases where a requested secret does not exist.
get_secret_names
from robocorp.vault import get_secret_names
Useful for listing available secret names, especially for debugging or dynamic access.

This quickstart demonstrates how to fetch a secret from the Robocorp Control Room Vault. It highlights accessing common attributes like `username` and `value`. Note that `robocorp-vault` is designed to run within a Robocorp environment, which automatically provides the necessary authentication context. For local development, specific environment variables must be configured to connect to your vault.

import os from robocorp.vault import get_secret, SecretNotFound # This example demonstrates how to retrieve a secret using robocorp-vault. # It requires a Robocorp environment (e.g., running within a Robocorp Task # or locally with appropriate environment variables like RC_API_SECRET_HOST # and RC_API_SECRET_TOKEN set to connect to your Control Room Vault). def access_my_example_secret(): secret_name = "MyTestSecret" # Replace with an actual secret name from your Control Room print(f"Attempting to retrieve secret: '{secret_name}'") try: # The get_secret function internally handles authentication using the # Robocorp environment context or configured API access details. secret = get_secret(secret_name) print(f"Successfully retrieved secret: {secret_name}") print(f" Username: {secret.username}") # For security, avoid printing raw passwords or sensitive values directly to logs. # print(f" Password: {secret.password}") if secret.value: print(f" Generic Value (first 5 chars): {secret.value[:5]}...") else: print(" This secret does not have a generic 'value'.") except SecretNotFound: print(f"Error: Secret '{secret_name}' not found. " "Please ensure it exists in your Robocorp Control Room Vault " "and the bot/robot has access permissions.") except Exception as e: print(f"An unexpected error occurred while accessing the vault: {e}") if __name__ == "__main__": # Simulate environment check for local execution. # In a real Robocorp run, these environment variables are automatically set. if not os.environ.get("RC_API_SECRET_HOST") and not os.environ.get("ROBOCORP_WORKITEM_STATE"): print("\n--- Local Execution Warning --- ") print("Running outside a Robocorp environment. Secret retrieval may fail.") print("To run locally, you need to configure RC_API_SECRET_HOST, RC_API_SECRET_TOKEN (or ROBOCORP_WORKITEM_STATE)") print("refer to Robocorp documentation for local testing secrets.") print("-------------------------------\n") access_my_example_secret()
Debug
Known issues
gotchaThe `robocorp-vault` library is designed to operate within a Robocorp execution environment (e.g., a Robocorp Task or Action). When running code locally outside this environment, you must manually configure specific environment variables (`RC_API_SECRET_HOST`, `RC_API_SECRET_TOKEN`, or `ROBOCORP_WORKITEM_STATE`) to enable communication with your Control Room Vault. Without these, `get_secret` calls will likely fail.
fix
For local development, refer to Robocorp's documentation on local setup and secret access. Ensure required environment variables are correctly set or use the Robocorp Lab/VS Code extension's local run features which handle this automatically.
affects: All versions
gotchaAttempting to retrieve a secret that does not exist or whose name is misspelled will raise a `robocorp.vault.SecretNotFound` exception. This can lead to unhandled crashes if not properly anticipated.
fix
Always wrap `get_secret()` calls in a `try...except SecretNotFound:` block to gracefully handle missing secrets. Verify secret names against your Control Room Vault settings.
affects: All versions
gotchaSensitive secret values (like passwords) should never be logged directly to console output, work item logs, or external systems, as this defeats the purpose of secure secret management. While `secret.password` and `secret.value` provide access to the data, exercise extreme caution.
fix
When debugging or indicating secret usage, use placeholder text or print only non-sensitive metadata (e.g., `secret.name`, `secret.description`). Avoid direct output of `secret.password` or `secret.value`.
affects: All versions
Errors
Common errors & fixes
robocorp.vault.errors.VaultNotConfiguredError: Robocorp Vault environment variables not set.
The program is attempting to access the Robocorp Vault API without the necessary `RP_VAULT_SECRET_ID` and `RP_VAULT_SECRET_VALUE` environment variables, which are essential for local development or when running outside the Robocorp Control Room environment.
fix
For local development, use `rp open` or `rp run` to initialize the environment, or manually set the `RP_VAULT_SECRET_ID` and `RP_VAULT_SECRET_VALUE` environment variables. When running in Robocorp Control Room, these variables are automatically provided.
AttributeError: 'NoneType' object has no attribute 'value'
The `vault.get_secret()` method returned `None` because a secret with the specified name does not exist in the configured vault, and the code subsequently tried to access an attribute (like `value`, `username`, or `password`) on this `None` object.
fix
Always check if the secret object returned by `vault.get_secret()` is not `None` before attempting to access its attributes. Example: `secret = vault.get_secret('my_secret'); if secret: print(secret.value)`.
ModuleNotFoundError: No module named 'robocorp.vault'
The `robocorp-vault` library has not been installed in the current Python environment or the active environment is not correctly configured to include it.
fix
Install the library using pip: `pip install robocorp-vault`
Upgrade
Version history
1.4.1latest on PyPI · released Aug 23, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
8
Bingbot
1
OpenAI (training)
1
Resources
robocorp-vault — pip install robocorp-vault · libregistry