Python (Flask and Django)
Shared helper (uses requests):
import os, requests
POL_API = "https://api.heliusnetwork.app"
POL_SECRET = os.environ["POL_SECRET"] # sk_...
def pol_siteverify(token, expected_action=None, expected_account_hint_hash=None):
data = {"secret": POL_SECRET, "response": token}
if expected_action:
data["expected_action"] = expected_action
if expected_account_hint_hash:
data["expected_account_hint_hash"] = expected_account_hint_hash
r = requests.post(f"{POL_API}/v1/siteverify", data=data, timeout=5)
return r.json()
Flask
from flask import Flask, request, abort
app = Flask(__name__)
@app.post("/signup")
def signup():
result = pol_siteverify(request.form.get("pol-token", ""))
if not result.get("success"):
abort(400, "Please complete the Proof-of-Life check.")
return "Welcome!"
Django
from django.http import HttpResponseBadRequest, HttpResponse
from django.views.decorators.http import require_POST
@require_POST
def signup(request):
result = pol_siteverify(request.POST.get("pol-token", ""))
if not result.get("success"):
return HttpResponseBadRequest("Please complete the Proof-of-Life check.")
return HttpResponse("Welcome!")
For step-up, call POST /v1/stepup/start from your view with secret, action and an account_hint_hash (an HMAC of your internal user id), return client_token to the browser, and verify with expected_action and expected_account_hint_hash.
Proof-of-Life is in early access. Request keys, read the API reference or the privacy notice.