当前,我尝试通过Keycloak的Admin REST API从curl命令创建用户. 我可以以管理员身份进行身份验证,我的回答很好,但是当我要创建用户时,会出现类似"404-Not Found"的错误.
Currently I try to create a user from curl command via Keycloak's Admin REST API. I can authenticate myself as an admin, I have a good answer, but when I want to create a user, I have an error like: "404 - Not Found".
这是我的curl命令:
Here are my curl commands:
#!/bin/bash echo "* Request for authorization" RESULT=`curl --data "username=pierre&password=pierre&grant_type=password&client_id=admin-cli" localhost:8080/auth/realms/master/protocol/openid-connect/token` echo "\n" echo "* Recovery of the token" TOKEN=`echo $RESULT | sed 's/.*access_token":"//g' | sed 's/".*//g'` echo "\n" echo "* Display token" echo $TOKEN echo "\n" echo " * user creation\n" curl localhost:8080/apiv2/users -H "Authorization: bearer $TOKEN" --data '{"firstName":"xyz","lastName":"xyz", "email":"demo2@gmail", "enabled":"true"}'我使用了位于以下地址的官方API文档: www.keycloak/docs-api/4.4/rest-api/index.html
I used the official API documentation, located at this address: www.keycloak/docs-api/4.4/rest-api/index.html
我有此错误:
我的境界很好
我该如何解决? 预先感谢.
How I can fix it? Thanks in advance.
推荐答案尝试一下,我添加了内容类型标头并修改了url:
try this, I added the content type header and modify the url :
#!/bin/bash echo "* Request for authorization" RESULT=`curl --data "username=admin&password=Pa55w0rd&grant_type=password&client_id=admin-cli" localhost:8080/auth/realms/master/protocol/openid-connect/token` echo "\n" echo "* Recovery of the token" TOKEN=`echo $RESULT | sed 's/.*access_token":"//g' | sed 's/".*//g'` echo "\n" echo "* Display token" echo $TOKEN echo "\n" echo " * user creation\n" curl -v localhost:8080/auth/admin/realms/apiv2/users -H "Content-Type: application/json" -H "Authorization: bearer $TOKEN" --data '{"firstName":"xyz","lastName":"xyz", "email":"demo2@gmail", "enabled":"true"}'更多推荐
通过curl命令在Keycloack上创建用户
发布评论