LessOTP Inbound WhatsApp Authentication client SDK for Python.
Project description
LessOTP Python SDK
Client for the LessOTP Inbound WhatsApp Authentication API (Python 3.8+).
Install
pip install lessotp-sdk
Usage
import os
from lessotp_sdk import LessOTPClient, parse_verified_webhook
# production (default)
client = LessOTPClient(api_key=os.environ["LESSOTP_API_KEY"])
# staging
staging = LessOTPClient(
api_key=os.environ["LESSOTP_STAGING_API_KEY"],
environment="staging",
)
# strict
strict = client.auth_request("6281234567890")
# frictionless
frictionless = client.auth_request()
# per-call override
one_off = client.auth_request("6281234567890", environment="staging")
# webhook verification
event = parse_verified_webhook(
request.get_data(as_text=True),
request.headers.get("X-Signature"),
os.environ["LESSOTP_WEBHOOK_SECRET"],
)
if event is None:
return "bad signature", 403
print(event.request_id, event.phone_number)
API
LessOTPClient(api_key, environment='production', base_url='https://api.lessotp.com', timeout_seconds=10)
| Option | Default | Description |
|---|---|---|
api_key |
required | App API key. |
environment |
"production" |
"production" or "staging". |
base_url |
https://api.lessotp.com |
API host. |
timeout_seconds |
10 |
HTTP timeout. |
client.auth_request(phone_number=None, environment=None) -> AuthRequestResult
Calls the endpoint selected by environment. The per-call environment overrides the client environment.
verify_webhook_signature(raw_body, signature_header, secret) -> bool
Constant-time HMAC-SHA256 verification. Accepts raw hex and sha256= prefixed values.
parse_verified_webhook(raw_body, signature_header, secret) -> VerificationSuccess | None
Returns the parsed payload if the signature is valid; None otherwise.
Errors
Raises LessOTPError on transport, auth, or payload problems.
Tests
python -m pip install -e ".[test]"
python -m pytest
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 lessotp_sdk-0.1.0.tar.gz.
File metadata
- Download URL: lessotp_sdk-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c06dddaa018af99c15fd40af946c8062b147943624a9e59db90163b6bb6f581
|
|
| MD5 |
112cbe398387e1afb6f15f03561e790b
|
|
| BLAKE2b-256 |
39bde7dd7fa00f4d128e7581295e49e561fb75891dc9696152fa0d12a43534fd
|
File details
Details for the file lessotp_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lessotp_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f37324df16e9317594722828481662949bd8a88632e571839d78c2fc849f57a
|
|
| MD5 |
48ef1ceadb3eea0b9e3ab8438530a875
|
|
| BLAKE2b-256 |
ee0c550e0a2460de2fe5f3520ad24688113323fe1ed2a30e029604d8bc47acb3
|