Keycloak: Registration to external database using User Storage SPI

The thing I understood is we need to have a User Storage SPI and have UserRegistrationProvider implemented.

This gives us the addUser method

    public UserModel addUser(RealmModel realm, String username) {

But this only contains the username parameter, how do we save password , along with first name, and last name in the database?

I thought I would be able to capture the password updateCredential , but this never got called after registering a new user?

The user can have different types of credentials. (Password, OTP)
To set one of the the types you need an extra call. This is also happening with the keycloak buildin usermodel.

Thank you @HenkN How is that extra call happening?

You can search the source code how it is done. I have no example at hand

The addUser method is „just“ for registering a record with your external storage and returning a reference back to Keycloak. Updating the attributes of this reference object (UserModel) is done with the default mechanisms for updating a user entity.

See also the build-in LDAPStorageProvider and the ExampleUserStorageProvider in the quickstarts.