Passkey Authentication

Register or log in a user using passkeys in Flutter

Register a new user with a passkey

To create a new user account with a passkey, provide the user’s email address or phone number to passage.passkey.register(). View a full registration implementation on GitHub.

final passage = PassageFlutter("YOUR_APP_ID");
 
void register(String identifier) async {
  try {
    // Register user
    await passage.passkey.register(identifier);
    // Retrieve new authenticated user info
    final PassageUser user = await passage.currentUser.userInfo();
  } catch (error) {
    if (error is PassageError &&
        error.code == PassageErrorCode.userCancelled) {
      // User cancelled passkey prompt, do nothing.
    } else {
      // Optionally try an email or sms registration method (see next page)
    }
  }
}

Log in an existing user with a passkey

To authenticate an existing user with their passkey, use passage.passkey.login. View a full implementation on GitHub.

void login(String identifier) async {
  try {
    await _passage.passkey.login(identifier);
    // Retrieve authenticated user info
    final PassageUser user = await passage.currentUser.userInfo();
  } catch (error) {
    if (error is PassageError &&
        error.code == PassageErrorCode.userCancelled) {
      // User cancelled passkey prompt, do nothing.
    } else {
      // Optionally try an email or login method (see next page)
    }
  }
}