1

I set up a keycloak server with LDAP users to take advantage of the SSO on my applications. I would like to change the password of the logged in user on my application through the Keycloak API. So, in the future, my Angular application will be able to make a request to the keycloak API to change the password of the logged-in user.

So I tried to do what is indicated in the documentation (method PUT, reset-password) but without success ... I did my tests with postman, I wonder if my token is the one to be used? Does the problem come from elsewhere?

I have this url : PUT {url}/auth/admin/realms/{realm}/users/{id user}/reset-password/

I have this header :

Content-type application/json

i have this body :

{
    "pass" : {
        "type": "password",
        "temporary": false,
        "value": "my-new-password"
    }
}

I get a 401 error if I did not try to renew the token quickly (which makes me say that the problem may not come from the token) and I get a 403 or 400 error when I got a new token via postman oAuth 2.0

I sometimes get this message:

Unrecognized field "pass" (class org.keycloak.representations.idm.CredentialRepresentation), not marked as ignorable

Please, help me !

You can see here my autorization in postman, i don't know what is "State"

Rikyuu
  • 13
  • 1
  • 3

3 Answers3

5

Body of PUT Should be CredentialRepresentation, which is

{
  "type":"password",
  "value":"my-new-password",
  "temporary":false
}
ravthiru
  • 8,878
  • 2
  • 43
  • 52
3

You can use POST method with these parametes:

URL:

http://[Server Address]/auth/admin/realms/[Realm Name]/users

Headers:

Content-Type application/json

Body:

{
    "username": "test",
    "firstName": "test",
    "lastName": "test",
    "email": "test@gmail.com",
    "enabled": true,
    "credentials": [{
        "type": "password",
        "value": "123456",
        "temporary": false
    }]
}
BluEiS
  • 157
  • 1
  • 5
0

Change pass to credentials.

it’s better to check current password to increase the security

KhalidAlsayed
  • 13
  • 1
  • 2