Registry / auth-security / secretstorage

secretstorage

JSON →
library3.5.0pypypi✓ verified 25d ago

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 SecretStorage
INSTALL
IMPORT
SIG · SECRETSTORAGE
S
secretstorage
auth-securitypythonv3.5.0
Install
2.8s avg
Import
56ms
Disk
34MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.5.0 · 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.058s · 35.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.8s · import 0.054s · 36MB
34MB installed
● package 34MB
Code
Verified usage

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

Collection
from secretstorage.collection import Collection
Correct import path for Collection class
Item
from secretstorage.item import Item
Correct import path for Item class
SecretStorageException
from secretstorage.exceptions import SecretStorageException
Correct import path for SecretStorageException class

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.

import secretstorage # Initialize D-Bus connection connection = secretstorage.dbus_init() # Access the default collection collection = secretstorage.get_default_collection(connection) # Create a new item attributes = {'application': 'myapp'} item = collection.create_item('My Secret Item', attributes, b'mysecretpassword') # Retrieve the secret secret = item.get_secret() print(secret.decode())
Debug
Known issues
breakingPython 3.10 or higher is required starting from version 3.4.0
fix
Upgrade to Python 3.10 or higher
affects: 3.4.0 and above
deprecatedThe int_to_bytes() function was removed in version 3.5.0
fix
Use the built-in int.to_bytes() method instead
affects: 3.5.0
gotchaThe secretstorage library failed to initialize D-Bus communication because the DBUS_SESSION_BUS_ADDRESS environment variable was not set.
fix
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.
affects: All versions
breakingSecretstorage requires a D-Bus session to be active, and the `DBUS_SESSION_BUS_ADDRESS` environment variable is not set, preventing D-Bus connection.
fix
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.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'secretstorage'
The 'secretstorage' package is not installed in the current Python environment.
fix
pip install secretstorage
secretstorage.exceptions.NoBackendError: No backend available.
The 'secretstorage' library could not find or connect to any FreeDesktop.org Secret Service implementation (like gnome-keyring or KDE KWallet) via D-Bus.
fix
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.
secretstorage.exceptions.SecretStorageException: Cannot connect to the secret service.
The 'secretstorage' library failed to establish a D-Bus connection to the FreeDesktop.org Secret Service, possibly due to the service not running, D-Bus issues, or permission problems.
fix
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.
dbus.exceptions.DBusException: org.freedesktop.Secret.Error.NoCollection
The requested secret collection (e.g., 'login') does not exist or is not available on the Secret Service backend.
fix
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.
Upgrade
Version history
3.5.0latest on PyPI · released Nov 23, 2025
Audit
Dependencies
JeepneyrequiredRequired for D-Bus communication
cryptographyrequiredProvides cryptographic recipes and primitives
Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
secretstorage — pip install secretstorage · libregistry