When token service fails, display the error

When https://www.privateinternetaccess.com/api/client/v2/token fails, such as with an "504 Gateway Time-out" error, display that error so the user knows what happened.
This commit is contained in:
Craig Andrews 2023-01-17 12:01:00 -05:00 committed by GitHub
parent e37693326d
commit 0cf65d3e8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,10 +69,18 @@ fi
echo -n "Checking login credentials..." echo -n "Checking login credentials..."
generateTokenResponse=$(curl -s --location --request POST \ generateTokenResponse=$(curl --fail-with-body -s --location --request POST \
'https://www.privateinternetaccess.com/api/client/v2/token' \ 'https://www.privateinternetaccess.com/api/client/v2/token' \
--form "username=$PIA_USER" \ --form "username=$PIA_USER" \
--form "password=$PIA_PASS" ) --form "password=$PIA_PASS" ) || {
echo
echo -e "${red}Could not authenticate with the login credentials provided!${nc}"
echo "Error response:"
echo $generateTokenResponse
echo
exit 1
}
if [ "$(echo "$generateTokenResponse" | jq -r '.token')" == "" ]; then if [ "$(echo "$generateTokenResponse" | jq -r '.token')" == "" ]; then
echo echo