{"library":"oso-cloud","title":"Oso Cloud Python Client","description":"Oso Cloud is an authorization-as-a-service platform. The Python client (`oso-cloud`) provides a convenient wrapper around the Oso Cloud HTTP API, enabling applications to interact with the service for modeling, storing, enforcing, querying, and testing authorization logic using the declarative Polar policy language. The library is currently at version 2.6.0 and demonstrates a healthy release cadence, with the last version released less than a year ago.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install oso-cloud"],"cli":{"name":"oso-cloud","version":"sh: 1: oso-cloud: not found"}},"imports":["from oso_cloud import Oso","from oso_cloud import Value","from oso_cloud import IntoValue","from oso_cloud import IntoFact"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom oso_cloud import Oso, Value\n\n# Initialize Oso Cloud client with an API key\n# Ensure OSO_AUTH environment variable is set or pass it directly:\n# oso = Oso(api_key=os.environ.get('OSO_AUTH', ''))\noso = Oso()\n\n# Define example data\nuser = Value(\"User\", \"alice\")\nrepository = Value(\"Repository\", \"my-repo\")\norganization = Value(\"Organization\", \"acme\")\n\nasync def run_auth_checks():\n    try:\n        # Insert a fact: Alice has the role 'owner' on 'my-repo'\n        await oso.insert((\"has_role\", user, \"owner\", repository))\n        print(f\"Inserted fact: Alice is owner of my-repo.\")\n\n        # Check if Alice can 'read' the 'my-repo' repository\n        # This assumes a policy has been uploaded to Oso Cloud, e.g.,\n        # allow(user: User, \"read\", repo: Repository) if has_role(user, \"owner\", repo);\n        is_allowed = await oso.check(user, \"read\", repository)\n        print(f\"Can Alice 'read' my-repo? {is_allowed}\")\n\n        # Query for all repositories Alice can 'read'\n        # Assumes a policy defining 'allow' rules.\n        readable_repos = []\n        async for result in oso.query(user, \"read\", Value(\"Repository\")):\n            if result.resource:\n                readable_repos.append(result.resource.id)\n        print(f\"Repositories Alice can read: {readable_repos}\")\n\n        # Delete the previously inserted fact\n        await oso.delete((\"has_role\", user, \"owner\", repository))\n        print(f\"Deleted fact: Alice is owner of my-repo.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Make sure OSO_AUTH environment variable is set with your Oso Cloud API key.\")\n\nimport asyncio\nasyncio.run(run_auth_checks())\n","lang":"python","description":"This quickstart demonstrates how to initialize the `oso-cloud` client, insert authorization facts, and perform permission checks and queries against the Oso Cloud service. It requires an active Oso Cloud account and an API key, which should be set as the `OSO_AUTH` environment variable. The examples assume a basic policy defining roles and permissions (e.g., an owner can read a repository) has been uploaded to your Oso Cloud instance.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"2.6.0","pypi_latest":"2.6.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.2,"avg_import_s":0.82,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.67,"mem_mb":12.5,"disk_size":"21.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.3,"import_time_s":0.49,"mem_mb":12.5,"disk_size":"22M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.95,"mem_mb":14.1,"disk_size":"23.9M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.3,"import_time_s":0.79,"mem_mb":14.1,"disk_size":"24M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.06,"mem_mb":14.1,"disk_size":"15.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":1.01,"mem_mb":14.1,"disk_size":"16M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.02,"mem_mb":15.3,"disk_size":"15.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.92,"mem_mb":15.2,"disk_size":"16M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.7,"mem_mb":12.1,"disk_size":"21.0M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"oso-cloud","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.5,"import_time_s":0.56,"mem_mb":12.1,"disk_size":"21M"}]}}