SecretStorage is a Python library that provides secure storage for passwords and other secrets using the FreeDesktop.org Secret Service API. The current version is 3.5.0, released on November 23, 2025. It requires Python 3.10 or higher and has a stable release cadence with regular updates addressing security and functionality improvements.
pip install SecretStorageVerified import paths — ran on the pinned version, not inferred.
This script demonstrates how to initialize a D-Bus connection, access the default collection, create a new secret item, and retrieve its secret using the SecretStorage library.
Upgrade to Python 3.10 or higher
Use the built-in int.to_bytes() method instead
Ensure the DBUS_SESSION_BUS_ADDRESS environment variable is properly configured in the execution environment. This typically involves running within a graphical desktop session or explicitly setting the variable (e.g., from `dbus-daemon --session --print-address` output) for headless environments.
Ensure a D-Bus session is available and `DBUS_SESSION_BUS_ADDRESS` is correctly set in the environment. This typically happens automatically in a graphical desktop environment. For headless environments or containers, D-Bus may need to be manually configured and started.
pip install secretstorage
Ensure a Secret Service backend (e.g., 'gnome-keyring-daemon') is running and accessible on the D-Bus session. This often requires being logged into a desktop environment or setting up the service explicitly in headless environments.
Verify that a Secret Service backend (e.g., 'gnome-keyring-daemon') is installed, running, and accessible. Restarting your desktop environment or ensuring the D-Bus session is properly configured often resolves this.
Create the collection if it's missing (e.g., through a desktop GUI like 'seahorse' or via 'secretstorage.collection.create_collection()') or ensure the correct collection name is being used.