private async Task <DocuSignAuthTokenDTO> ObtainAuthToken(CredentialsDTO curCredentials)
        {
            //TODO: choose configuration either for demo or prod service
            string endpoint = string.Empty;

            if (curCredentials.IsDemoAccount)
            {
                endpoint = CloudConfigurationManager.GetSetting("environment_DEMO") + "/restapi";
            }
            else
            {
                endpoint = CloudConfigurationManager.GetSetting("environment") + "/restapi";
            }

            // Here we make a call to API with X-DocuSign-Authentication to retrieve both oAuth token and AccountID
            string        integratorKey = CloudConfigurationManager.GetSetting("DocuSignIntegratorKey" + (curCredentials.IsDemoAccount ? "_DEMO" : ""));
            ApiClient     apiClient     = new ApiClient(endpoint);
            string        authHeader    = "{\"Username\":\"" + curCredentials.Username + "\", \"Password\":\"" + curCredentials.Password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";
            Configuration conf          = new Configuration(apiClient);

            conf.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
            AuthenticationApi authApi   = new AuthenticationApi(conf);
            LoginInformation  loginInfo = await authApi.LoginAsync(new AuthenticationApi.LoginOptions()
            {
                apiPassword = "******"
            });

            string accountId            = loginInfo.LoginAccounts[0].AccountId; //it seems that althought one DocuSign account can have multiple users - only one is returned, the one that credentials were provided for
            DocuSignAuthTokenDTO result = new DocuSignAuthTokenDTO()
            {
                AccountId     = accountId,
                ApiPassword   = loginInfo.ApiPassword,
                Email         = curCredentials.Username,
                IsDemoAccount = curCredentials.IsDemoAccount,
                Endpoint      = loginInfo.LoginAccounts[0].BaseUrl.Replace("v2/accounts/" + accountId.ToString(), "")
            };

            return(result);
        }