private async Task <OpenStackAuthResponse> OpenStackAuthenticate(string uri = null, string tenantName = null, string username = null, string password = null)
        {
            OpenStackAuthResponse authResponse = new OpenStackAuthResponse();

            using (var client = new HttpClient())
            {
                //create an object with the necessary TENANT, USERNAME, and PASSWORD parameters
                OpenStackAuthRequest myAuth = new OpenStackAuthRequest(tenantName, username, password);

                //initialize the HttpClient object with the auth endpoing URI
                client.BaseAddress = new Uri(uri);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //POST the OpenStackAuthHeader to the tokens method of the auth endpoint
                HttpResponseMessage response = await client.PostAsJsonAsync("tokens", myAuth);

                if (response.IsSuccessStatusCode)
                {
                    //get the response from the OpenStack auth service
                    authResponse = response.Content.ReadAsAsync <OpenStackAuthResponse>().Result;
                }
            }
            return(authResponse);
        }
        /// <summary>
        /// Authenticate against an OpenStack server
        /// </summary>
        /// <returns></returns>
        /// <remarks>Sample Usage:
        /// OpenStackClient.OpenStackClient osc = new OpenStackClient.OpenStackClient();
        /// osc.Username = "******";
        /// osc.Password = "******";
        /// osc.TenantName = "TenantName";
        /// osc.IdentityUrl = identityURI;
        /// </remarks>
        public async Task <OpenStackAuthResponse> Authenticate(string ServiceCatalogName)
        {
            OpenStackAuthResponse resp = new OpenStackAuthResponse();

            resp = await OpenStackAuthenticate(IdentityUrl, TenantName, Username, Password);

            this.token = resp.access.token;

            //find the public endpoint for the compute API (needed to spin up VM)
            foreach (ServiceCatalog sc in resp.access.serviceCatalog)
            {
                if (sc.name == ServiceCatalogName)
                {
                    resp.endPointUrl = sc.endpoints[0].publicURL;
                }
            }
            resp.tenantId = resp.access.token.tenant.id;

            return(resp);
        }