Passkey Authentication

Register or login a user using passkeys on Android

Register a new user with a passkey

To create a new user account with a passkey, pass the user’s email address or phone number to passage.passkey.register:

suspend fun register(identifier: String) {
    try {
        passage.passkey.register(identifier)
        // passage.getCurrentUser should now return the authenticated user
        val user = passage.currentUser.userInfo() ?: return
        // Do authenticated stuff
    } catch (e: RegisterWithPasskeyException) {
        // Optional: try registering with an email or sms registration method instead.
    }
}

Log in an existing user with a passkey

To log in an existing user with a passkey, call passage.passkey.login . You can call this method with or without an identifier:

suspend fun login(identifier: String) {
    try {
        passage.passkey.login(identifier)
        // passage.getCurrentUser should now return the authenticated user
        val user = passage.currentUser.userInfo() ?: return
        // Do authenticated stuff
    } catch (e: LoginWithPasskeyException) {
        // Optional: try logging in with an email or sms login method instead.
    }
}