-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathset_user.sh
executable file
·33 lines (29 loc) · 1.05 KB
/
set_user.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
IDP_HOST="172.17.0.1"
IDP_HOST="keycloak-ekyc"
ACCESS_TOKEN=$(curl --location --request POST "http://$IDP_HOST:8080/auth/realms/master/protocol/openid-connect/token" \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=admin' \
--data-urlencode 'client_id=admin-cli' \
--data-urlencode 'grant_type=password' | jq -r ".access_token")
curl --location --request POST "http://$IDP_HOST:8080/auth/admin/realms/demo/users" \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header 'Content-Type: application/json' \
--data-raw '{
"username":"test",
"firstName": "Joe",
"lastName": "Doe",
"email": "[email protected]",
"credentials":[
{
"type": "password",
"value": "test123",
"temporary": false
}
],
"enabled": "true"
}'
USER_ID=$(curl --location --request GET "http://$IDP_HOST:8080/auth/admin/realms/demo/users?username=test" \
--header "Authorization: Bearer $ACCESS_TOKEN" | jq -r ".[0].id")
echo "USER_ID: $USER_ID"