CORE-5505: only attempt to authenticate to the Foundation API when necessary and throw meaningful error messages when authentication fails