public static string GetAuthToken(string apiVersion, string serverType, string username, string password, string loginUrl)
        {
            string token;
            var    login       = new Login(username, password);
            var    apiInstance = new AuthApi(loginUrl);

            if (serverType == "Local") //get token from open source Server
            {
                try
                {
                    var     result  = apiInstance.ApiVapiVersionAuthTokenPostAsyncWithHttpInfo(apiVersion, login).Result.Data.ToString();
                    JObject jsonObj = JObject.Parse(result.Replace("[]", "null"));
                    Dictionary <string, string> resultDict = jsonObj.ToObject <Dictionary <string, string> >();
                    token = resultDict["token"].ToString();
                }
                catch (Exception ex)
                {
                    if (ex.Message != "One or more errors occurred.")
                    {
                        throw new InvalidOperationException("Exception when calling AuthApi.GetAuthToken: " + ex.Message);
                    }
                    else
                    {
                        throw new InvalidOperationException(ex.InnerException.Message);
                    }
                }
            }
            else //if (serverType == "Cloud" || serverType == "Documents") //get machine token for cloud Server
            {
                token = apiInstance.GetCloudToken(loginUrl, apiVersion, username, password);
            }

            return(token);
        }
        public static ServerInfo GetServerInfo(string apiVersion, string serverUrl, string token)
        {
            var apiInstance = new AuthApi(serverUrl);

            try
            {
                var result     = apiInstance.ApiVapiVersionAuthGetUserInfoGetAsyncWithHttpInfo(token, apiVersion).Result.Data.ToString();
                var serverInfo = JsonConvert.DeserializeObject <ServerInfo>(result);
                return(serverInfo);
            }
            catch (Exception ex)
            {
                if (ex.Message != "One or more errors occurred.")
                {
                    throw new InvalidOperationException("Exception when calling AuthApi.GetUserInfo: " + ex.Message);
                }
                else
                {
                    throw new InvalidOperationException(ex.InnerException.Message);
                }
            }
        }