问题
I am trying to create a new user via the REST API, and I'm sending this POST
POST /admin/realms/myrealm/users
Headers: Authorization: Bearer (generated token, this part is OK) Content-Type: application/json
Body:
{
"username": "rahul",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "rahul",
"lastName": "borse",
"email": "rahulborse@yahoo.com",
"credentials": [
{
"type": "password",
"value": "rahul"
}
]
}
The user is created normally, but the password doesn't work, when I try to login it claims I have invalid credentials.
回答1:
Try to add mapping "temporary": false
to credentials
:
{
"username": "rahul",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "rahul",
"lastName": "borse",
"email": "rahulborse@yahoo.com",
"credentials": [
{
"type": "password",
"value": "rahul",
"temporary": false
}
]
}
来源:https://stackoverflow.com/questions/58321304/defining-a-new-user-password-through-keycloak-rest-api