Adding Custom Credential Type

Hello,

I’ve extended credentials and added my own type. when I try to migrate those credentials into the keycloak via admin REST API and sending request body like"

"credentials": [
                {
                    "type": "MY_TYPE",
                    "secretData": "{\"secret\":\"123\"}"
                }
            ]

jboss logs warning: [org.keycloak.models.utils.RepresentationToModel] (default task-86) Using deprecated ‘credentials’ format in JSON representation for user ‘000’. It will be removed in future versions

as I find out, this warning is because that I’m not sending credentialData . My credential type does not need credentialData, so should I ignore this warning or send an empty credentialData in request body?

thanks in advance,

1 Like

Were you able to solve this Keycloak’s bug?

nope, I’m just sending the empty credentialData and this warning has disappeared

I am also getting this warning while importing users to keycloak with their BCRYPT password

{
        realm: AUTH_REALM_NAME,
        credentials: [
          {
            algorithm: 'bcrypt',
            hashedSaltedValue: existingUser.password, // the bcrypt-hashed password
            hashIterations: 10,
            type: 'password',
          },
        ],
        email: existingUser.email,
        username: existingUser.email,
        emailVerified: true,
        enabled: true,
        attributes: {
...
        },
}

which modifications should I do to use credentialData?

EDIT:
changing credentials to below format has fixed my issue

 credentials: [
          {
            type: 'password',
            secretData: JSON.stringify({
              value: existingUser.password,  // the bcrypt-hashed password
            }),
            credentialData: JSON.stringify({
              algorithm: 'bcrypt',
              hashIterations: 10,
            }),
          },
        ],

Reference: migration - Failing to create user with password via Keycloak Rest API - Stack Overflow