Last active
August 6, 2020 14:16
-
-
Save deftdawg/11a0b46fc44c5764acb6730431006a02 to your computer and use it in GitHub Desktop.
Simple shell script to Dyson API using curl and jq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Deftdawg's Dyson API test script | |
# Requires curl and jq | |
DYSON_SERVER="appapi.cp.dyson.com" | |
DYSON_EMAIL=${1} | |
DYSON_PASSWORD=${2} | |
if [ -z "${DYSON_EMAIL}" ] || [ -z "${DYSON_PASSWORD}" ]; then | |
echo "USAGE: $0 <DYSON ACCOUNT EMAIL> <DYSON ACCOUNT PASSWORD>" | |
exit 1; | |
fi | |
RESULT=$(curl -s -X POST -H "Content-Type: application/json" -k "https://${DYSON_SERVER}/v1/userregistration/authenticate" -d "{\"Email\": \"${DYSON_EMAIL}\", \"Password\": \"${DYSON_PASSWORD}\"}") | |
if ! echo "${RESULT}" | grep -q Password; then | |
echo "ERROR" | |
echo "${RESULT}" | jq | |
exit 2; | |
fi | |
echo "Auth Result" | |
echo "${RESULT}" | jq | |
DYSON_ACCOUNT=$(echo "${RESULT}" | jq -r .Account) | |
DYSON_BASIC_AUTH_PASSWORD=$(echo "${RESULT}" | jq -r .Password) | |
echo "API v1 endpoint" | |
curl -s -k "https://${DYSON_SERVER}/v1/provisioningservice/manifest" -u ${DYSON_ACCOUNT}:${DYSON_BASIC_AUTH_PASSWORD} | jq | |
echo "API v2 endpoint" | |
curl -s -k "https://${DYSON_SERVER}/v2/provisioningservice/manifest" -u ${DYSON_ACCOUNT}:${DYSON_BASIC_AUTH_PASSWORD} | jq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment