Enrollment follows a two-step pattern: enrollmentChallenge() to request the challenge, followed by enrollmentVerify() to complete the process.
Passkey
Requires handling WebAuthn credentials. You must convert base64url strings to ArrayBuffer and serialize the PublicKeyCredential into a plain object.
Email
Requires an email and the otpCode received by the user.
Phone
Requires a phone_number and the otpCode received via SMS or voice.
TOTP (Authenticator App)
Requires the otpCode generated by the user's app after scanning the provided barcode_uri.
<script>
import { useAuth0 } from '@auth0/auth0-vue';
export default {
setup() {
const { myAccount } = useAuth0();
// Example: Email Enrollment
const enrollEmail = async (email, otpCode) => {
const challenge = await myAccount.enrollmentChallenge({
type: 'email',
email
});
await myAccount.enrollmentVerify({
type: 'email',
location: challenge.location,
auth_session: challenge.auth_session,
otp_code: otpCode
});
};
// Example: TOTP Enrollment
const enrollTotp = async (otpCode) => {
const challenge = await myAccount.enrollmentChallenge({ type: 'totp' });
// challenge.barcode_uri can be rendered as a QR code
await myAccount.enrollmentVerify({
type: 'totp',
location: challenge.location,
auth_session: challenge.auth_session,
otp_code: otpCode
});
};
return { enrollEmail, enrollTotp };
}
};
</script>