keycloak-phone-provider: Error setting up SMS OTP
During the action “CONFIGURE_SMS_OTP” only get the following error:
Phone number not found
Looks to me like this error comes from here: https://github.com/cooperlyt/keycloak-phone-provider/blob/a7acd58101e79dfaa048261470ab4cba3fe16249/keycloak-phone-provider/src/main/java/cc/coopersoft/keycloak/phone/providers/rest/TokenCodeResource.java#L53
Looks to me like a bug because if I set up an SMS OTP I don’t need a phone number as a user property, right?
I would like to fix that, but I do not get where tokenCodeType comes from.
If you provide me with a bit more information, I can provide a PR.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 23
I am facing same problem here.
I have setup a fresh realm, and createed 2 users, A, B, and both of them do not have any phoneNumber attribute and not enrolled SMS OTP. Then I enabled Configure OTP over SMS required action in realm authentication.
When A login with his password, due to no SMS OTP configured, user A comes to configure OTP over SMS page. Now user A input his phone number N1 and click “Send Code”, but unfornately it shows “Phone number not found”, he cannot complete the SMS OTP setup and stuck there.
I checked the backend logic, it seems the js called the /realms/maple/sms/otp-code?phoneNumber=xxxxxx endpoint, in this endpoint, it searchs any user that have a attribute named phoneNumber and equals the phoneNumber parameter. If found, send the code, else it will return the message “Phone number not found”.
If I manually add phoneNumber attribute to user B with requested phoneNumber then login A with password, it sends the code correctly!!!
Actually, I dont understand the logic here, it’s very strange, if all users in realms do not have phoneNumber attribute, how can I enable the SMS OTP feature, I am really confused.
Perhaps the js should call /realms/maple/sms/registration-code?phoneNumber=xxxxxx in the SMS OTP enrollment page…