Skip to main content

Add your description here

Project description

Anzar SDK Documentation

Install The Python SDK

In a python project run the following command to install the anzar package. === "uv" bash $ uv add anzar === "pip" bash # in a virtual env run $ pip install anzar

Create Anzar Auth Instance

in your main entry file (main.py for example), import anzar.yml and parse it as a YAML file

def load_config(path: str) -> AnzarConfig:
    import yaml

    try:
        with open(path, "r") as f:
            data = yaml.safe_load(f)
        return AnzarConfig(**data)
    except Exception as e:
        import sys

        sys.exit("check your configuration file: anzar.yml")

import Anzar Auth and create your auth instance

# Initialize once at application startup
# The SDK will communicate with your Anzar container at the configured api_url
from anzar import Anzar

config = load_config("anzar.yml")
anzar = Anzar(config, options=None)

!!! danger Only extend these functionality if you are using JWT authentication

:warning: Implement a secure Storage solution
```python linenums="1"
from anzar.types import SdkOptions, SessionTokens

def refresh_token(tokens: SessionTokens):
    # store tokens.access, tokens.refresh
options = SdkOptions(
    get_token=lambda: "AccessToken"
    get_refresh_token=lambda: "RefreshToken"
    on_token_refresh=lambda tokens: refresh_token(tokens),
    ...
)
```
See [`SessionTokens`](../reference#tokens) for the full type definition.

Basic Usage

Anzar provides authentication support for email and password. !!! Notes Other methods of authentication will be implemented later

Sign Up

To sign up a user you need to call the method register with the user's information.

from anzar.types import ApiException, AuthResponse

try:
    data: AuthResponse = anzar.Auth.register({
      "username": "username",
      "email": "user@example.com",
      "password": "password"
    })
    if data.tokens:
        # Store securely the `access`,`refresh` tokens
except ApiException as e:
    print(e.status, e.body)

See AuthResponse for the full type definition.

!!! notes "Notes" By default, the users are automatically signed in after they successfully sign up.

Disabling this behavior will be implemented later

Sign In

To sign in a user you need to call the method login.

from anzar.types import ApiException, AuthResponse

try:
    data: AuthResponse = anzar.Auth.login({
      "email": "user@example.com",
      "password": "password"
    })
    if data.tokens:
        # Store securely the `access`,`refresh` tokens
except ApiException as e:
    print(e.status, e.body)

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

anzar-0.2.36.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anzar-0.2.36-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file anzar-0.2.36.tar.gz.

File metadata

  • Download URL: anzar-0.2.36.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for anzar-0.2.36.tar.gz
Algorithm Hash digest
SHA256 c62c1a2b323ccd76249ba94bf596857998dd85d29092631df42620da7d56a2e3
MD5 1a9d0777ca4879b372196de6a47eccb6
BLAKE2b-256 a76131e83d48e591c3b19d40faf28b70d95ea5781b97943f6f7419bb6e8b2165

See more details on using hashes here.

File details

Details for the file anzar-0.2.36-py3-none-any.whl.

File metadata

  • Download URL: anzar-0.2.36-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for anzar-0.2.36-py3-none-any.whl
Algorithm Hash digest
SHA256 02b045970278ca23ad92adb4748271b00a8bd9c0d73136107094fb0c71687a20
MD5 443936a0e9b9cb8857dd77bf5811f385
BLAKE2b-256 ae3f85e582951d4d86332844d1550976a8356ee0aa49ac110c229b0356654bfc

See more details on using hashes here.

Supported by

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