CLI: More robust handling of API errors
API Client: Add support for API authentication (currently only basic auth)