#!/usr/bin/env python3
"""
Option 2: Authorization using a token from the dashboard (Access section).
The token is passed in the request body as the "token" field.
"""
import requests
import json
# ===== CONFIGURATION =====
PROCESS_URL = "https://api.enface.ai/v1/kyc/process"
# Token from dashboard (Access section)
LK_TOKEN = "your-token-from-dashboard" # <-- insert token from dashboard (Access section)
SCHEMA_ID = "your-schema-id" # <-- insert schemaId from your dashboard
IMAGE_PATH = "path/to/your/image.jpg" # <-- path to the image
TIMEOUT = (30, 120)
# --- Send image with token in request body ---
print(f"Sending {IMAGE_PATH}...")
data = {
"token": LK_TOKEN,
"schemaId": SCHEMA_ID,
"mode": "sync",
}
with open(IMAGE_PATH, "rb") as f:
files = [("images", (IMAGE_PATH.split("/")[-1], f, "image/jpeg"))]
resp = requests.post(
PROCESS_URL,
data=data,
files=files,
timeout=TIMEOUT,
)
print(f"Status: {resp.status_code}")
try:
print(json.dumps(resp.json(), ensure_ascii=False, indent=2))
except Exception:
print(resp.text)