public async Task <AuthenticationResponse> AuthenticationMH()
        {
            HttpCustomClient client;
            string           stringResponse = string.Empty;

            if (authenticationResponse.expires_in == 0 || DateTime.Now > datetime.AddSeconds(authenticationResponse.expires_in))
            {
                #region Gets tokenObject
                try
                {
                    client = new HttpCustomClient();
                    Dictionary <string, string> authenticationDictionary = new Dictionary <string, string>
                    {
                        { Constants.Constants.grant_type, Constants.Constants.password },
                        { Constants.Constants.client_id, Constants.Constants.apiStag },
                        { Constants.Constants.client_secret, string.Empty },
                        { Constants.Constants.scope, string.Empty },
                        { Constants.Constants.username, ConfigurationManager.AppSettings[Constants.Constants.userATV] },
                        { Constants.Constants.password, ConfigurationManager.AppSettings[Constants.Constants.passwordATV] }
                    };

                    stringResponse = await client.SendRequest(authenticationDictionary, Constants.Constants.tokenEndpoint);

                    if (!string.IsNullOrEmpty(stringResponse))
                    {
                        authenticationResponse = JsonConvert.DeserializeObject <AuthenticationResponse>(stringResponse);
                    }
                    else
                    {
                        throw new Exception(Constants.Constants.fail_communication_oauth_hacienda);
                    }
                }
                catch (Exception ex)
                {
                    ex.Message.ToString();
                }
                #endregion
            }

            return(authenticationResponse);
        }
        public async Task <JsonResult> ListClient()
        {
            HttpCustomClient httpCustomClient = new HttpCustomClient();
            var request = new WebServiceRequest
            {
                MediaType = "application/json",
                Uri       = string.Format("{0}", ConfigurationManager.AppSettings["BillingWebApiUri"] + "client")
            };

            var response = await new HttpCustomClient().GetAsync(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var list = await Serialization.JsonStringToObject <IEnumerable <Client> >(response.Data.Content.ReadAsStringAsync().Result);

                return(Json(list, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("", JsonRequestBehavior.AllowGet));
            }
        }