Rest 无法使用KeyClope api创建用户

Rest 无法使用KeyClope api创建用户,rest,postman,keycloak,Rest,Postman,Keycloak,获取令牌成功: Post: http://localhost:8180/auth/realms/public-library/protocol/openid-connect/token Content type:application/x-www-form-urlencoded Body:x-www-form-urlencoded client_id:spring-boot-app username:pooja.kumawat password:poojakumawat@23 grant_typ

获取令牌成功:

Post: http://localhost:8180/auth/realms/public-library/protocol/openid-connect/token
Content type:application/x-www-form-urlencoded
Body:x-www-form-urlencoded
client_id:spring-boot-app
username:pooja.kumawat
password:poojakumawat@23
grant_type:password
 Output:Token
创建用户时出现错误:

Post : http://localhost:8180/auth/public-library/users
Authorization:Bearer+Token
Content type:Application/Json
Body:Raw
{
   "username": "name",
   "enabled": true,
   "emailVerified": false,
   "firstName": "first",
   "lastName": "last",
   "credentials": [
       {
           "type": "password",
           "value": "newPas1*",
           "temporary": false
       }
   ]
}
错误是:

{
"error": "RESTEASY003210: Could not find resource for full path: http://localhost:8180/auth/public-library/users"
}

看起来您使用了错误的端点,请将其更改为

http://localhost:8180/auth/admin/realms/public-library/users

请记住,执行
POST
请求的用户至少需要分配
管理用户
领域管理角色。否则响应将被403禁止

您需要做的是转到您在KeyClope中使用的领域。然后转到用户部分,选择用于请求的用户。在角色映射下,选择领域管理并为该用户分配角色领域管理员和管理用户角色。之后,您将能够发出请求

我更改了URL,现在它给出了{“错误”:“HTTP 401 Unauthorized”}然后您没有正确的身份验证,或者您的用户缺少所需的角色/权限(如我所述)-请首先检查,如果一切正常,错误应该消失(否则请检查KeyClope错误日志)