{"library":"pyobjc-framework-localauthentication","title":"PyObjC LocalAuthentication Framework","description":"Wrappers for the framework LocalAuthentication on macOS. This library is part of the larger PyObjC project, a bridge between Python and Objective-C. It allows Python applications to leverage macOS's biometric authentication (Face ID, Touch ID) and passcode features for secure user authentication. Currently at version 12.1, it maintains an active release cadence, typically aligning with macOS SDK updates and Python version support.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-localauthentication"],"cli":null},"imports":["from LocalAuthentication import LAContext","from LocalAuthentication import LAPolicy","from LocalAuthentication import LAError"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import objc\nfrom LocalAuthentication import LAContext, LAPolicy\n\ndef authenticate_user(reason=\"Authenticate to access sensitive data.\"):\n    context = LAContext.alloc().init()\n    error = objc.nil\n    can_evaluate = context.canEvaluatePolicy_error_(LAPolicy.deviceOwnerAuthenticationWithBiometrics, objc.byref(error))\n\n    if not can_evaluate:\n        if error is not objc.nil:\n            print(f\"Biometric authentication not available: {error.localizedDescription()}\")\n        else:\n            print(\"Biometric authentication not available.\")\n        # Fallback to device passcode if biometrics not available\n        can_evaluate = context.canEvaluatePolicy_error_(LAPolicy.deviceOwnerAuthentication, objc.byref(error))\n        if not can_evaluate:\n            if error is not objc.nil:\n                print(f\"Device passcode authentication not available: {error.localizedDescription()}\")\n            else:\n                print(\"Device passcode authentication not available.\")\n            return False\n\n    def reply_handler(success, err):\n        if success:\n            print(\"Authentication successful!\")\n        elif err is not objc.nil:\n            print(f\"Authentication failed: {err.localizedDescription()}\")\n        else:\n            print(\"Authentication failed (unknown error).\")\n\n    context.evaluatePolicy_localizedReason_reply_(LAPolicy.deviceOwnerAuthentication, reason, reply_handler)\n\n# Example usage:\n# Note: This will block the Python interpreter until authentication completes or fails.\n# In a real GUI app, this would typically be run on a background thread or using a runloop.\nauthenticate_user()\n\n# To run PyObjC event loop in a console application (optional, for persistent UI/callbacks):\n# from PyObjCTools import AppHelper\n# AppHelper.runEventLoop() # This should be called if you need to keep a UI or callbacks alive.","lang":"python","description":"This quickstart demonstrates how to use `LAContext` to evaluate an authentication policy, typically for biometric authentication (Face ID/Touch ID) or device passcode. It first checks if the policy can be evaluated and then calls `evaluatePolicy_localizedReason_reply_` with a callback function to handle the authentication result. Remember that `pyobjc-framework-localauthentication` is a macOS-only library and requires user interaction via a system prompt.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":null,"pypi_latest":"12.1","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.8,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.5,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyobjc-framework-localauthentication","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.4,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}