Keeper Secrets Manager Core

17.2.0 · active · verified Thu Apr 16

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

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `SecretsManager` using a one-time access token (preferably from an environment variable) and retrieve secrets. The one-time token is used for initial device registration and configuration file creation (e.g., `client-config.json`). After the initial setup, the SDK can often be initialized without the token, relying on the local configuration.

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`.")

view raw JSON →