Keyrings-alt

5.0.2 · active · verified Fri Apr 10

Keyrings-alt is a Python package that provides alternative backend implementations for the `keyring` library, enabling password storage solutions across various environments. It's currently at version 5.0.2 and maintains an active release cadence, often aligning with `keyring` library updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how `keyrings-alt` integrates with the `keyring` library. Once `keyrings-alt` is installed, its alternative backends become available for `keyring` to discover and use automatically. The example shows setting and retrieving a password, and identifying the active keyring backend.

import keyring
import os

# keyrings-alt, once installed, provides additional backends
# that the 'keyring' library automatically discovers and uses.

service_name = "my-app-service"
username = "test-user"
password = os.environ.get('KEYRING_TEST_PASSWORD', 'super-secret-password-123')

print(f"Using keyring for service '{service_name}', user '{username}'.")

# Set a password. The 'keyring' library will try to use the best available backend,
# which might be one provided by keyrings-alt if no stronger native keyring is present.
keyring.set_password(service_name, username, password)
print(f"Password set for service '{service_name}' user '{username}'.")

# Retrieve the password
retrieved_password = keyring.get_password(service_name, username)

print(f"Retrieved password: {'*' * len(retrieved_password) if retrieved_password else 'None'}")

if retrieved_password == password:
    print("Password retrieved successfully and matches original.")
else:
    print("Password retrieval failed or did not match.")

# You can inspect the currently active keyring backend
current_keyring = keyring.get_keyring()
print(f"\nCurrently active keyring backend: {current_keyring.__class__.__name__}")

view raw JSON →