Skip to main content

Client library for the Authzed service.

Project description

Authzed Python Client

This repository houses the Python client library for Authzed.

The library maintains various versions the Authzed gRPC APIs. You can find more info on each API on the Authzed API reference documentation. Additionally, Protobuf API documentation can be found on the Buf Registry Authzed API repository.

Supported API versions:

  • v1alpha1
  • v0
  • arrakisclient (v0 Legacy ORM)

Installation

pip install authzed

Example

Everything API specific is in its respective authzed.api.VERSION module. grpcutil contains functionality for making interacting with gRPC simple.

from authzed.api.v1alpha1 import Client, ReadSchemaRequest
from grpcutil import bearer_token_credentials


client = Client("grpc.authzed.com:443", bearer_token_credentials("mytoken"))
resp = client.ReadSchema(ReadSchemaRequest(object_definitions_names=["example/user"]))
print(resp.object_definitions)

If an event loop is running when the client is initialized, all functions calls are async:

import asyncio

from authzed.api.v1alpha1 import Client, ReadSchemaRequest
from grpcutil import bearer_token_credentials


async def async_new_client():
    # Within an async context, the client's methods are all async:
    client = Client("grpc.authzed.com:443", bearer_token_credentials("mytoken"))
    resp = await client.ReadSchema(ReadSchemaRequest(object_definitions_names=["example/user"]))
    print(resp)

loop = asyncio.get_event_loop()
try:
    loop.run_until_complete(async_new_client())
finally:
    loop.close()

Full Examples

Full examples for each version of the API can be found in the examples directory.

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

authzed-0.3.0.tar.gz (61.1 kB view hashes)

Uploaded Source

Built Distribution

authzed-0.3.0-py3-none-any.whl (79.3 kB view hashes)

Uploaded Python 3

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