Skip to main content

The 1Password Python SDK offers programmatic read access to your secrets in 1Password in an interface native to Python.

Project description

1Password Python SDK

Build integrations that programmatically access your secrets in 1Password.

Documentation | Examples


Requirements

The 1Password Python SDK is compatible with:

  • python 3.9 or later
  • libssl 3
  • glibc 2.32 or later

If you're running a Linux distribution that still uses libssl version 1.1.1, such as Debian 11 or Ubuntu 20.04, you'll need to update to a later version of Linux or install the required dependencies.

🚀 Get started

To use the 1Password Python SDK in your project:

  1. Create a service account and give it the appropriate permissions in the vaults where the items you want to use with the SDK are saved.

  2. Provision your service account token. We recommend provisioning your token from the environment. For example, to export your token to the OP_SERVICE_ACCOUNT_TOKEN environment variable:

    macOS or Linux

    export OP_SERVICE_ACCOUNT_TOKEN=<your-service-account-token>
    

    Windows

    $Env:OP_SERVICE_ACCOUNT_TOKEN = "<your-service-account-token>"
    
  3. Install the 1Password Python SDK in your project:

    pip install onepassword-sdk
    
  4. Use the Python SDK in your project:

import asyncio
import os
from onepassword.client import Client

async def main():
    # Gets your service account token from the OP_SERVICE_ACCOUNT_TOKEN environment variable.
    token = os.getenv("OP_SERVICE_ACCOUNT_TOKEN")

    # Connects to 1Password. Fill in your own integration name and version.
    client = await Client.authenticate(auth=token, integration_name="My 1Password Integration", integration_version="v1.0.0")

    # Retrieves a secret from 1Password. Takes a secret reference as input and returns the secret to which it points.
    value = await client.secrets.resolve("op://vault/item/field")
    # use value here

if __name__ == '__main__':
    asyncio.run(main())

Make sure to use secret reference URIs with the syntax op://vault/item/field to securely load secrets from 1Password into your code.

Supported functionality

1Password SDKs are in active development. We're keen to hear what you'd like to see next. Let us know by upvoting or filing an issue.

Item management

Operations:

Field types:

  • API Keys
  • Passwords
  • Concealed fields
  • Text fields
  • Notes
  • SSH private keys (partially supported: supported in resolving secret references, not yet supported in item create/get/update)
  • SSH public keys, fingerprint and key type
  • One-time passwords
  • URLs
  • Websites (used to suggest and autofill logins)
  • Phone numbers
  • Credit card types
  • Files attachments and Document items

Vault management

  • Retrieve vaults
  • Create vaults (#36)
  • Update vaults
  • Delete vaults
  • List vaults

User & access management

  • Provision users
  • Retrieve users
  • List users
  • Suspend users
  • Create groups
  • Update group membership
  • Update vault access & permissions

Compliance & reporting

Authentication

📖 Learn more

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onepassword_sdk-0.1.2.tar.gz (19.6 MB view hashes)

Uploaded Source

Built Distributions

onepassword_sdk-0.1.2-cp312-cp312-win_amd64.whl (3.6 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

onepassword_sdk-0.1.2-cp312-cp312-manylinux_2_32_x86_64.whl (4.3 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.32+ x86-64

onepassword_sdk-0.1.2-cp312-cp312-manylinux_2_32_aarch64.whl (4.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.32+ ARM64

onepassword_sdk-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (3.7 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

onepassword_sdk-0.1.2-cp312-cp312-macosx_10_9_x86_64.whl (4.0 MB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

onepassword_sdk-0.1.2-cp311-cp311-win_amd64.whl (3.6 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

onepassword_sdk-0.1.2-cp311-cp311-manylinux_2_32_x86_64.whl (4.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.32+ x86-64

onepassword_sdk-0.1.2-cp311-cp311-manylinux_2_32_aarch64.whl (4.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.32+ ARM64

onepassword_sdk-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (3.7 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

onepassword_sdk-0.1.2-cp311-cp311-macosx_10_9_x86_64.whl (4.0 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

onepassword_sdk-0.1.2-cp310-cp310-win_amd64.whl (3.6 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

onepassword_sdk-0.1.2-cp310-cp310-manylinux_2_32_x86_64.whl (4.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.32+ x86-64

onepassword_sdk-0.1.2-cp310-cp310-manylinux_2_32_aarch64.whl (4.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.32+ ARM64

onepassword_sdk-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (3.7 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

onepassword_sdk-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl (4.0 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

onepassword_sdk-0.1.2-cp39-cp39-win_amd64.whl (3.6 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

onepassword_sdk-0.1.2-cp39-cp39-manylinux_2_32_x86_64.whl (4.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.32+ x86-64

onepassword_sdk-0.1.2-cp39-cp39-manylinux_2_32_aarch64.whl (4.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.32+ ARM64

onepassword_sdk-0.1.2-cp39-cp39-macosx_11_0_arm64.whl (3.7 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

onepassword_sdk-0.1.2-cp39-cp39-macosx_10_9_x86_64.whl (4.0 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page