Skip to content

Instantly share code, notes, and snippets.

@anavarre
Last active September 21, 2023 14:09
Show Gist options
  • Save anavarre/fd690265f90cfa8784a4c5e5147be337 to your computer and use it in GitHub Desktop.
Save anavarre/fd690265f90cfa8784a4c5e5147be337 to your computer and use it in GitHub Desktop.
Acquia CLI / Federated Authentication Troubleshooting
#!/usr/bin/env bash
ACLI_LOG_FILE="/tmp/acli_fedauth.log"
info() {
echo "---------------------------------------------------------------------------------"
echo "Read this known issue first: https://docs.acquia.com/acquia-cli/known-issues/#id1"
echo "---------------------------------------------------------------------------------"
echo ""
}
check_requirements() {
MINOR=$(acli --version | cut -c 14-15)
echo "Troubleshooting:"
echo ""
[[ $(command -v acli) ]] && echo "- OK: Acquia CLI is correctly installed." || { echo "ERROR: Acquia CLI was not found."; exit 0; }
[[ ${MINOR} -ge 14 ]] && echo "- OK: Acquia CLI is running version 2.14.0 or above." || { echo "- ERROR: Acquia CLI version should at least be 2.14.0. Run acli self-update"; exit 0; }
[[ ! -d "${HOME}/.acquia-php-sdk-v2" ]] && echo "- OK: The Acquia CLI cache directory is correctly removed." || { echo "- ERROR: Delete your Acquia CLI cache directory (~/.acquia-php-sdk-v2)."; exit 0; }
[[ -z "${AH_ORGANIZATION_UUID}" ]] && { echo "- ERROR: You need to define the AH_ORGANIZATION_UUID environment variable."; exit 0; } || echo "- OK: The AH_ORGANIZATION_UUID environment variable is set to ${AH_ORGANIZATION_UUID}."
}
validate_organization_uuid() {
acli api:organizations:list &>"${ACLI_LOG_FILE}"
if [[ $(grep -c "invalid_scope" "${ACLI_LOG_FILE}") -eq 1 ]]; then
echo "- ERROR: The AH_ORGANIZATION_UUID environment variable seems to be invalid."
exit 0
else
echo "- OK: The AH_ORGANIZATION_UUID seems to be correct."
if [[ $(grep -o "${AH_ORGANIZATION_UUID}" "${ACLI_LOG_FILE}" | head -n1) ]]; then
echo "- OK: The AH_ORGANIZATION_UUID environment variable you have set matches our records."
else
echo "- ERROR: Your AH_ORGANIZATION_UUID environment variable does not match any Acquia organization UUID. Either this UUID does not exist or you need to re-authenticate Acquia CLI."
fi
fi
}
info
check_requirements
validate_organization_uuid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment