How Do Authenticator Apps Work? (TOTP, Secrets, Clock Drift & Safer Alternatives)

Authenticator apps generate short-lived 6–8 digit codes using TOTP (Time-based One-Time Passwords). Your app and the website share a secret key (seed). Every 30 seconds they both compute the same code from that secret + the current time. If your phone’s clock drifts, codes can fail.

What is an authenticator app?

An authenticator app (Google Authenticator, Microsoft Authenticator, Authy, etc.) is a second factor in multi-factor authentication (MFA). Instead of SMS codes, the app generates codes offline on your device. Most apps implement the TOTP standard (RFC 6238), which is built on HMAC-SHA1/256/512 with a rotating time counter.

Want to see TOTP in action? Try our TOTP Authenticator tool.

Why apps over SMS?

For background theory, see our earlier explainer: What is TOTP?

How TOTP actually works (step-by-step)

  1. Seed (secret) is provisioned When you enable 2FA, the service gives you a base32-encoded secret (the seed). You scan a QR code or paste a key.
  2. Both sides compute a moving counter Time is split into windows (typically 30 seconds). The counter = current Unix time ÷ step.
  3. HMAC the counter with the secret The app computes HMAC(secret, counter) using SHA-1/256/512.
  4. Dynamic truncation → 6–8 digit code A chunk of the HMAC output is converted to an integer and reduced mod 10^digits (e.g., 10^6 → 6 digits).
  5. Server verifies The server repeats the same calculation. If your code matches within an allowed window (e.g., current ±1 step), you’re in.

Parameters you’ll see:

Seed provisioning: QR codes & otpauth:// URI

When you click “Enable authenticator app” in any supported apps or website, a QR is displayed with an otpauth:// URI. Scanning it imports the seed and settings.

Example otpauth:// URI

After you enable the authenticator app, a recovery code is usually provided, and you should store recovery codes immediately! (see below)

Time drift (clock skew) and why codes sometimes fail

TOTPs depend on the current time. If your phone clock is off, your codes may not match the server’s:

If you’re building auth, Authgear supports TOTP, recovery codes, and passkeys out of the box—so you can offer strong MFA without the complexity.

Recovery codes

If you lose or wipe your phone, that TOTP seed is gone—so you’ll need recovery codes:

Phishing-resistant alternatives: WebAuthn / Passkeys

TOTPs can still be phished: an attacker can proxy your login and relay your one-time code in real time. WebAuthn (passkeys) is different:

How to use an authenticator app

  1. In supported services, go to Security → Two-Factor Authentication.
  2. Choose Authenticator app on your device.
  3. Scan the QR in your app (or paste the key).
  4. Enter the 6-digit code shown in your app to confirm.
  5. Download recovery codes and store them safely.

Recommended apps:

FAQ: How do authenticator apps work?

How do authenticator apps work without the internet?

They compute codes locally from a shared secret + time. Once the seed is on your device, it doesn’t need network access.

Can I move my authenticator to a new phone?

Yes, but you must transfer seeds or re-enrol. Some apps support encrypted backups/sync. Otherwise, use each service’s recovery codes to re-set TOTP on the new device.

Why are my codes “incorrect”?

Most common causes: wrong account, wrong digit length, or clock drift. Ensure 6 digits, 30-second period, and correct device time.

Are authenticator apps safer than SMS?

Yes. They’re not tied to your phone number and resist SIM-swap. However, they are not fully phishing-resistant; WebAuthn / passkeys are.

What’s the difference between TOTP and HOTP?

TOTP changes codes based on time; HOTP is counter-based (code increments per use). Most consumer apps use TOTP.