A code is sent when the identifier is a phone number, or when the app's email_auth_type is "otp". Code length and expiry are app settings.
Send#
signInOrUp, signIn and signUp send the code for you and return { otp: { id } }. To send one directly:
await scute.sendLoginOtp("+14155550100");// sign-up, with profile fields:await scute.sendRegisterOtp("ada@example.com", { first_name: "Ada" });otp_pending fires on success.
Verify#
const { data, error } = await scute.verifyOtp(code, "ada@example.com");if (error) return showError(error.message);if ("authPayload" in data) { await scute.signInWithTokenPayload(data.authPayload); // signed_in fires} else { showNextStep(data); // MFA or a contact to confirm}verifyOtp(otp, identifier) looks the user up by identifier, then checks the code. It does not sign in by itself: it returns { authPayload, magicPayload } for signInWithTokenPayload, or a sign-in step (mfaRequired or contactVerificationRequired, see MFA).
| error | Cause |
|---|---|
| IdentifierNotRecognizedError | No user with that identifier. |
| BaseHttpError | Wrong or expired code, or another refusal. error.json.error holds the API's message. |
Test identities#
In a sandbox workspace, test emails and phone numbers accept the code 424242 and nothing is sent.