TOTP stands for Time-based One-Time Passwords and is a common form of two factor authentication (2FA). Unique numeric passwords are generated with a standardized algorithm that uses the current time as an input. The time-based passwords are available offline and provide user friendly, increased account security when used as a second factor.
Example TOTP accounts in an authenticator app
TOTP is also known as app based authentication, software tokens, or soft tokens. Authentication apps like Authy and Google Authenticator support the TOTP standard.
2FA adds an extra layer of account protection by requiring two types of authentication. This can be something a user knows, like a password, and something the user has, like a phone. One-time passwords, including TOTP, are a common possession or "something you have" factor and help increase the security of your users accounts.
A recent study about the usability of 2FA methods found that TOTP had the highest usability score of the various second factors tested. This tells us that TOTP is not only a viable method for authentication, but will be preferred by many users.
system usability scale (SUS) scores show TOTP is most usable
The TOTP algorithm follows an open standard documented in RFC 6238. The inputs include a shared secret key and the system time. The diagram below shows how the two parties can separately calculate the passcode without internet connectivity.
The algorithm uses a form of symmetric key cryptography: the same key is used by both parties to generate and validate the token.
The inputs to the TOTP algorithm are device time and a stored secret key. Neither the inputs nor the calculation require internet connectivity to generate or verify a token. Therefore a user can access TOTP via an app like Authy while offline.
TOTP's offline support is ideal for users who might need to access their authentication while traveling abroad, on a plane, in a remote area, or otherwise without network connectivity.
While SMS is an ideal solution for 2FA adoption and ease of use, TOTP has several benefits including:
Most customers end up implementing multiple forms of 2FA so their users can choose the channel that works best for them. Other channels Twilio Verify supports include push, voice, and email. This blog post takes a more detailed look at the security concerns of SMS 2FA.
HOTP stands for HMAC-based One-Time Password and is the original standard that TOTP was based on. Both methods use a secret key as one of the inputs, but while TOTP uses the system time for the other input, HOTP uses a counter, which increments with each new validation. With HOTP, both parties increment the counter and use that to compute the one-time password.
The HOTP standard is documented in RFC 4226.
While HOTP is still used, consumer authenticator apps like Authy and Google Authenticator implement the TOTP standard.
Verify TOTP is in Pilot
This Verify feature is currently in the Pilot maturity stage, which means that:
1. We're actively looking for early-adopter customers to try it out and give feedback. That could be you!
2. You'll need to contact sales to request access to the API.
3. We're actively developing this feature and it could change/break unexpectedly; please only use in a test environment, not in production.
4. Usage is currently free, but billing will commence at a list price of $0.05 per verification when this feature enters the Public Beta maturity stage shortly after October 22, 2021. Technical details here.
Here's the code to create a TOTP factor. Follow the TOTP Quickstart for more details about how to generate a QR code and validate tokens.
Here is an example of a TOTP generated with the Verify API inside the Authy App. Tokens expire in 30 seconds by default, but you can change the expiration period when you create a Factor.
TOTP support through a consumer authenticator app is widely available, PII-less, and offers increased security. TOTP is a great solution for both providing a good user experience and strong authentication. Many companies now offer TOTP support as a step up from SMS based 2FA.
Check out these resources for more information on Twilio's APIs for multi channel user verification: