2024-10-08 22:34:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# API base URL
|
2024-10-21 16:28:30 +00:00
|
|
|
API_BASE_URL="http://localhost:8080/api/v1"
|
2024-10-08 22:34:49 +00:00
|
|
|
|
|
|
|
# Login credentials
|
|
|
|
USERNAME="boxuser"
|
|
|
|
PASSWORD="boxuser"
|
|
|
|
|
|
|
|
# Get a new JWT token
|
|
|
|
TOKEN=$(curl -s -X POST -H "Content-Type: application/json" \
|
|
|
|
-d "{\"username\":\"$USERNAME\", \"password\":\"$PASSWORD\"}" \
|
|
|
|
"$API_BASE_URL/login" | jq -r '.token')
|
|
|
|
|
|
|
|
# Request all items using the obtained token
|
|
|
|
response=$(curl -s -X GET -H "Authorization: Bearer $TOKEN" \
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
"$API_BASE_URL/items")
|
|
|
|
|
|
|
|
# Print the response
|
|
|
|
echo "$response"
|