Back to all articles
Security

What Is an OTP and Why Do You Keep Getting One?

OTP stands for one-time password — a temporary code sent to your phone or email to verify it's really you. Here's what it is, where it's used, how it works, and the one rule that keeps you safe.

6 min readSamson Ameh
#Security#OTP#Authentication#2FA#Online Safety

What Is an OTP and Why Do You Keep Getting One?

You try to log into a website, make a payment, or reset your password, and before anything happens a code arrives on your phone. You type it in, and you're through.

That code is an OTP — a one-time password. It shows up in more places than most people realise, and understanding what it does (and doesn't do) is worth a few minutes.


What OTP stands for

OTP stands for One-Time Password. It's a temporary code — usually sent via SMS or email — that a service uses to confirm you are the person who owns the account.

The length varies. Some services send 4 digits, others send 6, some send 8. The number itself doesn't matter — what matters is that it was sent to your registered contact and expires quickly.


Where OTPs actually show up

People often associate OTPs with banking, but they're used across a much wider range of situations:

  • Account login — some services send a code every time you log in instead of (or in addition to) a password
  • Online payments — card networks like Mastercard and Visa use OTPs to verify that the person making a payment online is the actual cardholder (this is what 3D Secure does)
  • Password reset — when you say "I forgot my password," the service sends a code to confirm you own the account before letting you create a new password
  • Email or phone verification — when you sign up for a new service and they ask you to confirm your contact details
  • Two-factor authentication (2FA) — adding a second layer of security to any login, even when you already know the password
  • App onboarding — first-time setup of financial or identity-sensitive apps often requires OTP verification
  • Transaction confirmation — some services ask you to confirm a specific action (like changing your email or deleting your account) with a code

The common thread: OTPs appear whenever a service needs to confirm that the person performing an action has access to a registered phone number or email address.


How the OTP flow works

The flow is the same regardless of what triggered it:

Step 1: You initiate something

You try to log in, make a payment, reset a password — anything that needs verification.

Step 2: The server generates a code

The service's server creates a unique, random code and ties it to your account and this specific request. It sets a short expiry — typically 5 to 10 minutes.

Step 3: The code is sent to you

It arrives via SMS to your registered phone number, or via email. Some apps display it directly in an authenticator app (more on that below).

Step 4: You enter it

You type the code into the prompt before it expires.

Step 5: The server checks it

The server checks three things:

  • Does this code match what we sent?
  • Is it still within the time window?
  • Has it been used before?

If all three check out, the action proceeds. If any fail, access is denied and you request a new code.

Step 6: The code is marked as used

That code is now dead. It cannot be entered again — not by you, not by anyone. Even if the time window hasn't closed yet.


Why OTP exists — the problem it solves

A password alone has a fundamental weakness: once someone else has it, they can use it whenever they want.

Passwords get leaked in data breaches. They get guessed. People reuse them across sites. A database gets hacked somewhere and suddenly your credentials are for sale online.

An OTP solves this by adding a second factor that changes every time. Even if someone has your password, they still need the code that was just sent to your phone. They'd have to have your password and access to your phone at the same time. That's a much harder combination to pull off.

This is the core idea behind two-factor authentication (2FA): something you know (password) plus something you have (your phone).


SMS OTP vs. app-based OTP

There are two main ways OTP codes reach you:

SMS OTP The server sends a text message to your phone number. Simple, works on any phone, no app needed. The downside: SMS can be intercepted through SIM swap fraud (where someone gets your number transferred to their SIM card), and it depends on mobile network availability.

App-based OTP (TOTP) Apps like Google Authenticator, Microsoft Authenticator, and Authy generate codes locally on your phone using a time-based algorithm (called TOTP — Time-based One-Time Password). No network request is needed to generate the code. The app and the server both know a shared secret key, and they both compute the same code for the current 30-second window.

App-based OTP is more secure because:

  • Nothing is transmitted over a network that can be intercepted
  • SIM swap doesn't affect it — the code lives on your device
  • It works without mobile signal

NIST (the US National Institute of Standards and Technology) recommends app-based OTP over SMS for sensitive accounts.


What OTP is not

A few common misconceptions:

OTP is not the same as a password. A password is something you create and reuse. An OTP is generated by the system, used once, and thrown away.

OTP does not replace a password. It works alongside one. The combination of password + OTP is what makes the security meaningful.

OTP does not mean you're being hacked. Receiving an OTP you didn't request is a signal that someone tried to log into your account using your credentials — but they haven't succeeded yet. Change your password if this happens unexpectedly.

Not all logins use OTP. Many apps (including banking apps) let you log in with just biometrics or a PIN for routine access. OTP is typically triggered for higher-risk actions: first login on a new device, online payments, sensitive account changes.


The threats against OTP

OTP is strong but not unbreakable. The main ways attackers try to get around it:

SIM swap — the attacker convinces your carrier to transfer your number to their SIM. SMS OTPs then go to them. Solution: use app-based OTP where possible.

Phishing — the attacker creates a fake login page, captures your password and OTP in real time, and immediately uses both on the real site. Solution: check the URL before entering anything. The OTP is only valid for a short window, so the attacker must act fast — which is why these attacks are automated.

Social engineering — someone calls pretending to be customer support and asks you to read them the code. No legitimate service does this. The code is for you to enter on the site — not to read to anyone.


The one rule

Never share your OTP with anyone.

Not with someone who calls saying they're from support. Not with someone who emails asking you to confirm it. Not with a form you were directed to from a link in a message.

The OTP is proof that you have access to your phone or email. The moment you share it with someone else, you've handed them that proof.

Any service that asks you to share your OTP is either poorly designed or fake.


Sources

Samson Ameh

Written by

Samson Ameh

Frontend Engineer specialising in React, TypeScript, and enterprise UI systems. Based in Lagos, Nigeria.