get_access_token.sh
#
curl -X POST http://localhost:8080/realms/myrealm/protocol/openid-connect/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=password" \
-d "client_id=myclient01" \
-d "client_secret=U7NTfODXUhLd4K9JwAVYpTvX6ghlRIu6" \
-d "username=scott" \
-d "password=hello9" > access_token.json
実行
./get_access_token.sh
パスワードが違った時の実行結果
{"error":"invalid_grant","error_description":"Invalid user credentials"}
Httpie を使った場合
go_httpie.sh
URL="http://localhost:8080/realms/myrealm/protocol/openid-connect/token"
#
http --form POST $URL \
"grant_type=password" \
"client_id=myclient01" \
"client_secret=U7NTfODXUhLd4K9JwAVYpTvX6ghlRIu6" \
"username=scott" \
"password=hello9" > access_token.json
#