How One-Time Password (OTP) flows work
mainThe OTP process relies on a shared secret between a user and a server.
- Shared Secret: Both parties agree on a stable secret in advance.
- Challenge: The server may send a challenge (e.g., a timestamp for TOTP) that the user must solve using the secret.
- Code: The user's client generates a numeric code (the OTP) which is sent to the server for validation.
Implementation Note: The client and server must use identical configurations, specifically the number of code digits and the HMAC algorithm (e.g., SHA1, SHA256, SHA512).
Code Digits: Codes are returned as String to preserve leading zeroes. While RFC 4226 recommends 6-8 digits, this library allows explicit configuration for shorter lengths if allowInsecureConfiguration = true is set.