Python Sample Applications
Minimal Examples
Minimal Client-Direct Example
import requests
FIDO_SERVER_URL = "https://fido.example.com"
USERNAME = "[email protected]"
RP_ID = "example.com"
# Registration
def register_user():
# Phase 1: Get registration options
begin_response = requests.post(
f"{FIDO_SERVER_URL}/fidoapi/certify/attestation/options",
json={"username": USERNAME, "rpId": RP_ID}
)
begin_data = begin_response.json()
challenge = begin_data["challenge"]
# Phase 2: Card operations (performed by mobile app with SDK)
# Mobile app returns card_response_data after calling registerCardOnly()
card_response_data = {
"id": "credential-id",
"rawId": "base64-raw-id",
"type": "public-key",
"response": {
"authenticatorData": "base64-data",
"clientDataJSON": "base64-data",
"signature": "base64-signature"
}
}
# Phase 3: Complete registration
complete_response = requests.post(
f"{FIDO_SERVER_URL}/fidoapi/certify/attestation/result",
json=card_response_data,
cookies=begin_response.cookies
)
print("Registration:", complete_response.json())
# Authentication
def authenticate_user():
# Phase 1: Get authentication options
begin_response = requests.post(
f"{FIDO_SERVER_URL}/fidoapi/certify/assertion/options",
json={"username": USERNAME, "rpId": RP_ID}
)
begin_data = begin_response.json()
# Phase 2: Card operations (performed by mobile app with SDK)
# Mobile app returns card_response_data after calling authenticateCardOnly()
card_response_data = {
"id": "credential-id",
"rawId": "base64-raw-id",
"type": "public-key",
"response": {
"authenticatorData": "base64-data",
"clientDataJSON": "base64-data",
"signature": "base64-signature"
}
}
# Phase 3: Complete authentication
complete_response = requests.post(
f"{FIDO_SERVER_URL}/fidoapi/certify/assertion/result",
json=card_response_data,
cookies=begin_response.cookies
)
print("Authentication:", complete_response.json())Minimal Backend-Proxied Example
Complete Sample Applications
Client-Direct Pattern
Basic Client-Direct Example
Backend-Proxied Pattern (Recommended)
Backend API Client
Complete Backend-Proxied Authentication Example
Integration with Mobile Apps
Backend Flow
Example: Flask Backend Endpoint
Error Handling
Session Management
Complete Example: Flask Application
Last updated

