Adding authentication API, a keep-alive session, and error handling