Skip to content

    Hap 5.1 Authorization Code ◎

    auth_code = 
        "identifier": generate_uuid(),
        "timestamp": now_utc() + 300,  # 5 min expiry
        "signature": ed25519_sign(challenge, controller_private_key)
    return base64_encode(encrypt(auth_code, accessory_public_key))
    

    | Method | Primary Use | Duration | |--------|-------------|----------| | Setup Code | First-time ownership | Permanent (until reset) | | Authorization Code | Secondary controller addition | Single use / 5 min | | Long-term key | Ongoing control | Months | | Session key | One encrypted session | Hours |

    If your app uses implicit intents (e.g., "Open a PDF viewer" or "Open a URL"), you do not need to name specific packages, but you must declare the intent actions you intend to query. hap 5.1 authorization code

    Code Example:

    <queries>
        <!-- Authorize viewing of web URLs (Browsers) -->
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
    <!-- Authorize text processing apps -->
        <intent>
            <action android:name="android.intent.action.PROCESS_TEXT" />
            <data android:mimeType="text/plain" />
        </intent>
    </queries>
    
  • Additional Controller Authorization

  • Ownership Transfer / Reset with Authorization | Method | Primary Use | Duration |

  • Role/Capability Granting