Menu

WhatsApp OTP login with SMS fallback: 3 bugs that cost us sign-ups
📰

WhatsApp OTP login with SMS fallback: 3 bugs that cost us sign-ups

DEV Community: android·RollHire·about 1 hour ago
#PfDWPIMV
#devtoandroid#devto#dev#code#whatsapp
Long article (397 words) — no AI summary yet.
Reading 0:00
15s threshold

Most of our users in India are delivery riders, guards, pickers and telecallers signing up on budget Android phones. SMS OTP was our biggest sign-up leak: messages arrived late or not at all, and every resend cost money. We moved the primary OTP channel to WhatsApp and kept SMS as a fallback. Here's how it works and the bugs we hit.

The flow

The client calls a serverless function /send with the phone number.

The function normalises the number to E.164, finds or creates the auth user, generates a 6-digit code, and sends it through a WhatsApp Business authentication template.

Only a SHA-256 hash of userId:code is stored in the user's prefs, with an expiry and an attempt counter.

/verify compares hashes, counts attempts, and on success mints a short-lived session token the client exchanges for a session.

If WhatsApp delivery fails, /send returns { fallback: "sms" } and the client falls back to the platform's SMS OTP.

Rate limits that don't lock real users out

A per-number minimum gap between sends, and…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.