One-Time Passwords in Keycloak
- Type
- Concept
- For
- Keycloak administrators
- Checked against
- Keycloak 26.8.2
- Owner
- Karan Deshmukh
- Last review
- 2026-11-27
A one-time password (OTP) is a short code that an authenticator app computes from a secret it shares with Keycloak. With the realm's default policy, the code has 6 digits and changes every 30 seconds. A user who signs in with a password and a code proves two things: what they know, and that they hold the phone.
The OTP Credential
Keycloak stores the shared secret as a credential of the user, next to their password. On the user's Credentials tab, it's the row of type Otp, and its user label names the device, such as Alex's phone.
Keycloak keeps no copy of the secret that the user can reach. When the phone is lost, so is the authenticator: the only way back is to delete the credential and set up a new one.
Required Actions
A required action is something a user must do at their next sign-in, before Keycloak lets them in. Configure OTP is the required action that makes a user set up an authenticator.
Why Deleting the Credential Isn't Enough
Keycloak's default browser flow asks for a code only from a user who has a second factor configured. In Keycloak 26.8.2, that step is the subflow Browser - Conditional 2FA, and its first condition is Condition - user configured.
So when an administrator deletes a user's OTP credential, nothing asks for a code at the next sign-in, and nothing asks the user to set up a new authenticator. The user signs in with their password alone, until an administrator adds the Configure OTP required action.
Deleting an OTP credential leaves the account with one factor. Sign the user out, and add the Configure OTP required action before you delete the credential. Reset a User's OTP Credential does it in that order.