Skip to main content

Official server-side SDK for ThirdFactor

Project description

ThirdFactor Python SDK

Official server-side SDK for the ThirdFactor identity verification API.

Keep your ThirdFactor API key on the server. Never expose it in browser or mobile application code.

Installation

pip install thirdfactor-sdk

Python 3.9 or newer is supported. The SDK has no runtime dependencies.

Create a verification session

import os

from thirdfactor import ThirdFactor

tf = ThirdFactor(
    api_key=os.environ["THIRDFACTOR_API_KEY"],
    base_url="https://your-tenant.thirdfactor.ai",
)

session = tf.sessions.create(
    vendor_data="user-42",
    workflow_id="4c615aec-e173-450d-8089-30d4edc835f3",
    callback_url="https://example.com/kyc/done",
    idempotency_key="kyc-user-42",
)

print(session["url"])
decision = tf.sessions.decision(session["id"])

The workflow_id comes from GET /v3/workflows/:

workflows = tf.request("GET", "/v3/workflows/")

Verify webhooks

Webhook handlers must pass the untouched request bytes, before JSON parsing:

event = tf.webhooks.construct_event(raw_body, signature_header, "whsec_...")

Invalid or stale signatures raise SignatureError. The default replay window is five minutes.

Handle API errors

from thirdfactor import APIError

try:
    session = tf.sessions.retrieve("session-id")
except APIError as error:
    print(error.status, error.body, error.request_id)

See the ThirdFactor documentation for API, workflow, decision, and webhook details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thirdfactor_sdk-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thirdfactor_sdk-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file thirdfactor_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: thirdfactor_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for thirdfactor_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6f652dd5d6f61303987167d2ae2d316aeb0dec916cbb7a48999e7b3241aa11fd
MD5 3791379387a8d8090bd5aca1cfadd8fc
BLAKE2b-256 95f96a3c2980f06375228f9d152d8cc8c0c63c533801954331196ba84db421be

See more details on using hashes here.

File details

Details for the file thirdfactor_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for thirdfactor_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cdf546daf020773966dfe17945c0daf98b567886e9c88310612a072d6922eebc
MD5 1dc8f4338bc5a94429a252fe38b528e2
BLAKE2b-256 4154fcbdeccc8abc5108451b228b697183b4b22eb73564e1fe55779b19ea716d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page