{"id":6017,"library":"onepassword-sdk","title":"1Password Python SDK","description":"The 1Password Python SDK (version 0.4.0) offers programmatic read and write access to your secrets, vaults, and user/group permissions within 1Password. It supports authentication via the 1Password desktop app or 1Password Service Accounts, and is currently in its 0.x version series, indicating a rapid release cadence with ongoing feature additions.","status":"active","version":"0.4.0","language":"en","source_language":"en","source_url":"https://github.com/1Password/onepassword-sdk-python","tags":["security","secrets management","1password","authentication"],"install":[{"cmd":"pip install onepassword-sdk","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Requires Python 3.9 or later.","package":"Python","optional":false},{"reason":"Required for Linux distributions. Older versions like libssl 1.1.1 (e.g., Debian 11, Ubuntu 20.04) are not supported without an update.","package":"libssl 3","optional":false},{"reason":"Required for Linux distributions. Older versions are not supported without an update.","package":"glibc 2.32","optional":false}],"imports":[{"note":"Primary client class for interacting with the 1Password API.","symbol":"Client","correct":"from onepassword.client import Client"},{"note":"Used for authenticating via the 1Password desktop application.","symbol":"DesktopAuth","correct":"from onepassword.client import Client, DesktopAuth"}],"quickstart":{"code":"import asyncio\nimport os\nfrom onepassword.client import Client\nfrom onepassword.models import FieldPurpose\n\nasync def main():\n    # Authenticate using a 1Password Service Account token from environment variable\n    token = os.environ.get(\"OP_SERVICE_ACCOUNT_TOKEN\")\n    if not token:\n        print(\"Error: OP_SERVICE_ACCOUNT_TOKEN environment variable not set.\")\n        return\n\n    # Connect to 1Password with your integration details\n    client = await Client.authenticate(\n        auth=token,\n        integration_name=\"My Test Integration\",\n        integration_version=\"v1.0.0\",\n    )\n\n    # Example: Retrieve a secret using a secret reference\n    # Replace 'op://vault/item/field' with your actual secret reference URI\n    try:\n        secret_value = await client.secrets.resolve(\"op://MyVault/MyLoginItem/password\")\n        print(f\"Retrieved secret: {secret_value}\")\n\n        # Example: List vaults (requires appropriate permissions)\n        vaults = await client.vaults.list()\n        print(f\"Found {len(vaults)} vaults:\")\n        for vault in vaults:\n            print(f\"- {vault.name} (ID: {vault.id})\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n    finally:\n        # Ensure the client connection is closed (if applicable, though often handled internally)\n        pass\n\nif __name__ == '__main__':\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to authenticate with the 1Password SDK using a Service Account token provided via an environment variable (`OP_SERVICE_ACCOUNT_TOKEN`). It then shows how to resolve a secret using a 1Password secret reference and how to list available vaults. Remember to replace placeholder values like 'op://MyVault/MyLoginItem/password' and ensure your service account has the necessary permissions."},"warnings":[{"fix":"Consult the official release notes and migration guides for each minor version upgrade to adapt your code. Patch releases (0.x.y to 0.x.z) should not contain breaking changes.","message":"The SDK is currently in version 0.x, which means breaking changes are possible between minor versions (e.g., 0.1.x to 0.2.0). Review release notes carefully when upgrading to a new minor version.","severity":"breaking","affected_versions":"0.x series (e.g., 0.1.x -> 0.2.x)"},{"fix":"Update your Linux distribution to a newer version or manually install the required `libssl 3` and `glibc 2.32` dependencies.","message":"On Linux, the SDK requires `libssl 3` and `glibc 2.32` or later. Older distributions (e.g., Debian 11, Ubuntu 20.04) running `libssl 1.1.1` will encounter errors.","severity":"gotcha","affected_versions":"All 0.x versions on affected Linux systems"},{"fix":"Ensure you install `onepassword-sdk` for direct account access (desktop app or service account authentication) or `onepasswordconnectsdk` if you are using a 1Password Connect server.","message":"There are two distinct Python SDKs for 1Password: `onepassword-sdk` (for direct 1Password account interaction) and `onepasswordconnectsdk` (for self-hosted 1Password Connect servers). Using the wrong SDK for your deployment method will lead to connection or authentication failures.","severity":"gotcha","affected_versions":"All 0.x versions"},{"fix":"Choose the appropriate authentication method for your use case and follow the official documentation for setup, including creating a Service Account token or enabling desktop app integration in 1Password settings.","message":"The SDK supports two primary authentication methods: 1Password desktop app (for local, human-in-the-loop) and 1Password Service Accounts (for automated access). Each requires specific setup and configuration.","severity":"gotcha","affected_versions":"All 0.x versions, especially from 0.4.0 onward with desktop app integration"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}