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
$ uv add anzar
pip
# 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)
⚠️ Warning: Only extend these functionality if you are using JWT authentication
⚠️ Warning: Implement a secure Storage solution
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),
...
)
Basic Usage
Anzar provides authentication support for email and password.
📝 Note: 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)
📝 Note: 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anzar-0.3.0.tar.gz.
File metadata
- Download URL: anzar-0.3.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
767263bede9a770c2a3b324bdfaaa84bf43f85c12c4b49a14edac8a714350104
|
|
| MD5 |
714974af0365c617faf7737062358b63
|
|
| BLAKE2b-256 |
423b1d9f4c84cc082923e2394f006fa2b934a3d66eedc80431194c1091ed95e2
|
File details
Details for the file anzar-0.3.0-py3-none-any.whl.
File metadata
- Download URL: anzar-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ca1f268c6dbf68b46ff7cbc5263552e971ab6a52732c2777f2ab3e5631e12b4
|
|
| MD5 |
6e7ecc77df7e932e0c2fea2220fd8426
|
|
| BLAKE2b-256 |
1ef070636543e43d4ccef408c4c9c082adfb26e69b6d626e199d1a57e1bb6c67
|