markdown
Celonix OTP - Python
WhatsApp OTP authentication for Python applications.
Works with Flask, Django, FastAPI, or any Python framework.
Install
pip install celonix-otp
Usage
python
from celonix_otp import CelonixOTP
otp = CelonixOTP()
# Send OTP
request_id = otp.send_otp("919876543210", "https://myapp.com")
print(f"OTP sent! Request ID: {request_id}")
# Verify OTP
is_valid = otp.verify_otp(request_id, "472891")
if is_valid:
print("Login successful!")
else:
print("Wrong OTP")
Flask Example
python
from flask import Flask, request, jsonify
from celonix_otp import CelonixOTP
app = Flask(__name__)
otp = CelonixOTP()
@app.route("/send-otp", methods=["POST"])
def send_otp():
phone = request.json.get("phone")
origin = request.headers.get("Origin", "")
try:
request_id = otp.send_otp(phone, origin)
return jsonify({"request_id": request_id, "status": "sent"})
except Exception as e:
return jsonify({"error": str(e)}), 400
@app.route("/verify-otp", methods=["POST"])
def verify_otp():
request_id = request.json.get("request_id")
otp_code = request.json.get("otp")
try:
is_valid = otp.verify_otp(request_id, otp_code)
return jsonify({"verified": is_valid})
except Exception as e:
return jsonify({"error": str(e)}), 400
if __name__ == "__main__":
app.run(debug=True)
Django Example
python
# views.py
from django.http import JsonResponse
from celonix_otp import CelonixOTP
otp = CelonixOTP()
def send_otp_view(request):
phone = request.POST.get("phone")
origin = request.META.get("HTTP_ORIGIN", "")
try:
request_id = otp.send_otp(phone, origin)
return JsonResponse({"request_id": request_id})
except Exception as e:
return JsonResponse({"error": str(e)}, status=400)
def verify_otp_view(request):
request_id = request.POST.get("request_id")
otp_code = request.POST.get("otp")
try:
is_valid = otp.verify_otp(request_id, otp_code)
return JsonResponse({"verified": is_valid})
except Exception as e:
return JsonResponse({"error": str(e)}, status=400)
FastAPI Example
python
from fastapi import FastAPI, Request
from celonix_otp import CelonixOTP
app = FastAPI()
otp = CelonixOTP()
@app.post("/send-otp")
async def send_otp(request: Request):
data = await request.json()
origin = request.headers.get("origin", "")
request_id = otp.send_otp(data["phone"], origin)
return {"request_id": request_id}
@app.post("/verify-otp")
async def verify_otp(data: dict):
is_valid = otp.verify_otp(data["request_id"], data["otp"])
return {"verified": is_valid}
Need Domain Whitelisting?
Send your website URL to admin@celonix.in
text
Save the file.
Tell me when done.
Metadata
Release files for celonix-otp 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| celonix_otp-1.0.0.tar.gz | 3.8 kB | Without provenance | Details for celonix_otp-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| celonix_otp-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for celonix_otp-1.0.0-py3-none-any.whl |
Total release size: 8.0 kB
Release files / celonix_otp-1.0.0.tar.gz
| Download URL | celonix_otp-1.0.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22d7a2cf19b41847d2ebccb54c1ffc83e17ae63d0c1337bc0e441f15abef6c7e
|
|
BLAKE2b-256 checksum How to use checksums |
b3ea1bf69765a7375935f7b8ad1fb208b1acccff499dee1a55d5bfdcb3ecd52c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / celonix_otp-1.0.0-py3-none-any.whl
| Download URL | celonix_otp-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30effe15e966ddd997273abd38ea63263bac683fe9aaeac4736a3f2a7ad7dc3a
|
|
BLAKE2b-256 checksum How to use checksums |
e586a6aea9ee987afa8da0d51c76c2a39bcc6534b693024449694112656195d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for celonix-otp 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.