BASH, cURL script to retrieve Google Analytics data

Last week I wrote this PowerShell code to retrieve Google Analytics data. Below is similar code in BASH using the cURL command.

stty -echo
read -p "Password: " password; echo
stty echo
RESULT=$(curl -s \
--data-urlencode [email protected] --data-urlencode Passwd=$password \
-d accountType=GOOGLE \
-d source=YourSource \
-d service=analytics)

AUTH=$(echo "$RESULT" | grep 'Auth=' | sed  s/Auth=//)

curl -s "" \
--request GET --header "Authorization: GoogleLogin auth=$AUTH"


Comments are closed.