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.registerWithPasskey:

suspend fun register(identifier: String) {
    try {
        passage.registerWithPasskey(identifier)
        // passage.getCurrentUser should now return the authenticated user
        val user = passage.getCurrentUser() ?: 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.loginWithPasskey which will show any/all user's passkeys available for login for your app:

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

Last updated