Skip to content

Biometrics

See the Biometrics guide.

Biometric authentication (Face ID, Touch ID, and fingerprint).

Enable it in pythonnative.toml. On iOS, face_id supplies the reason the system prompt shows:

[plugins]
use = ["biometrics"]

[permissions]
face_id = "Unlock your vault."

Biometrics gates an action behind the device's biometric hardware through LAContext (iOS) and BiometricPrompt (Android).

Example
from pythonnative.biometrics import Biometrics

async def unlock():
    if await Biometrics.authenticate("Unlock your vault"):
        show_secrets()

Classes:

Name Description
Biometrics

Biometric authentication interface.

Biometrics

Biometric authentication interface.

Raises:

Type Description
NativeModuleError

If the native module fails, or with the code plugin_not_enabled when biometrics isn't in the build.

Methods:

Name Description
is_available

Return True when biometric auth can be attempted (enrolled hardware; False off device).

authenticate

Present the biometric prompt; resolve True on success, False on failure or cancel.

is_available staticmethod

is_available() -> bool

Return True when biometric auth can be attempted (enrolled hardware; False off device).

authenticate async staticmethod

authenticate(reason: str = 'Authenticate') -> bool

Present the biometric prompt; resolve True on success, False on failure or cancel.