'Keycloak OTP based Login

I want to enable login in my application using following call flow:

Step 1: User visits the Application website and enters the Mobile Number or Username.

Step 2: Application requests Keycloak to generate the OTP for the user associated with the username. The OTP returned by Keycloak is sent to User via Email or SMS.

Step 3: User enters the OTP and the application sends the OTP to Keycloak to validate against that user.

Step 4: Keycloak validates the OTP and responds back with Access Token.

In the above call flow, I need 2 APIs from Keycloak.

  1. API to generate the OTP for given username
  2. API to validate the OTP provided by the User and respond back with Access Token

Please let me know if this login call flow is possible or not using the latest Keycloak version.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source