Keeper Secrets Manager Core
Keeper Secrets Manager Core is the Python SDK for Keeper's cloud-based, zero-knowledge secrets management platform. It allows developers to securely access and manage sensitive credentials like API keys, database passwords, and SSH keys in CI/CD pipelines, containers, and automation scripts. The library is actively maintained with frequent updates, with the current stable version being 17.2.0.
Common errors
-
requests.exceptions.SSLError: HTTPSConnectionPool(...): Max retries exceeded with url: .../authentication/...
cause Network proxy performing packet inspection, or invalid SSL certificate configuration preventing secure connection to Keeper servers.fixAllow direct access to Keeper security domains (`keepersecurity.com`, etc.) through your firewall/proxy. If using a proxy, ensure `verify_ssl_certs` and `proxy_url` are configured correctly. -
Record not Found
cause Attempting to retrieve a legacy (non-V3) or untyped record, which is not supported by Keeper Secrets Manager. Also can occur if the record UID is incorrect or permissions are insufficient.fixEnsure the record is a 'typed' record (V3) and that the configured device has appropriate permissions to access it. Verify the record UID is correct. -
access_denied
cause The Secrets Manager add-on is not enabled for your Keeper Account, or the role associated with the device does not have the Secrets Manager enforcement policy enabled.fixVerify that the Secrets Manager add-on is active on your Keeper Account and that the role used by the application/device has the Secrets Manager enforcement policy enabled in the Admin Console. -
Throttling error (e.g., HTTP 503 response code)
cause The Keeper Secrets Manager API throttles requests based on the Device ID. Excessive requests from a single device ID can trigger throttling.fixImplement retry logic with exponential backoff in your application to handle throttled requests. Review application design to minimize rapid, repetitive API calls from a single device ID. -
TypeError: 'list' object is not callable (or similar when accessing a record field)
cause Incorrectly attempting to access a secret field value, possibly confusing the `field()` method (which returns a specific field) with direct attribute access, or misinterpreting multi-value fields.fixUse the `secret.field('field_name', single=True)` method for standard fields, or iterate if expecting multiple values. Refer to the SDK documentation for correct field access patterns.
Warnings
- breaking Minimum Python version raised to 3.9 in `keeper-secrets-manager-core` v17.2.0. Users on Python 3.6-3.8 will automatically install the latest v17.1.x release, which continues to receive security/bug fixes until August 2026.
- gotcha The SDK creates a `client-config.json` file to store connection and encryption information. On Unix, this file is created with 0600 (owner-only) permissions; on Windows, secure ACLs are applied. Warnings may be issued if permissions are too open.
- gotcha SSL certificate errors (`requests.exceptions.SSLError`) can occur if network proxies attempt packet inspection, as Keeper traffic is encrypted end-to-end and cannot be intercepted.
- gotcha Keeper Secrets Manager only supports typed records (V3). Attempting to retrieve a legacy, non-typed record will result in a 'record not found' error.
- gotcha The one-time access token used for initial device registration and configuration (`SecretsManager(token=...)`) can expire. If it expires, SDK initialization will fail.
Install
-
pip install keeper-secrets-manager-core
Imports
- SecretsManager
from keeper_secrets_manager_core import SecretsManager
Quickstart
import os
from keeper_secrets_manager_core import SecretsManager
# The one-time access token is typically generated via Keeper Web Vault or Commander CLI.
# It's recommended to retrieve it from an environment variable for production.
ONE_TIME_TOKEN = os.environ.get('KEEPER_ONE_TIME_TOKEN', 'US:YOUR_ONE_TIME_TOKEN_HERE') # Replace with your token
try:
# Initialize the Secrets Manager. This will create or load the client-config.json file.
# The token is only needed for initial setup; subsequent calls can omit it if config exists.
secrets_manager = SecretsManager(token=ONE_TIME_TOKEN)
print("SecretsManager initialized successfully.")
# Retrieve all secrets accessible by the configured device.
all_secrets = secrets_manager.get_secrets()
if all_secrets:
print(f"Retrieved {len(all_secrets)} secrets.")
for secret in all_secrets:
print(f" Title: {secret.title}, UID: {secret.uid}")
# Example: Access a standard field like 'password'
try:
password = secret.field('password', single=True)
# print(f" Password: {password}") # WARNING: Do not print sensitive data in production
except Exception as e:
print(f" No 'password' field found or error: {e}")
else:
print("No secrets found.")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure 'KEEPER_ONE_TIME_TOKEN' environment variable is set or the token in code is valid.")
print("For initial setup, a one-time access token is required to create `client-config.json`.")