private static HttpClient InitializeHttpClient(EasyAccessToken token, string url)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(url);

            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            client.DefaultRequestHeaders.Clear();

            //Use correct authorization, bearer + token
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token.Access_Token);

            return(client);
        }
        public static async Task <HttpClient> Connect(string username, string password, string url)
        {
            var authCtx = new AuthenticationContext(ClientCredentials, new TokenCache())
            {
                AuthorityUri = new Uri(AuthorityUri)
            };

            try
            {
                Debug.WriteLine("Acquiring TID token for Easy Access...");

                EasyAccessToken eaToken = await GetEasyAccessToken(authCtx, username, password);

                Debug.WriteLine("Acquired Easy Access token.");
                Debug.WriteLine("Token: " + eaToken.Access_Token);

                return(InitializeHttpClient(eaToken, url));
            } catch (Exception e)
            {
                Debug.WriteLine(e.StackTrace);
                throw new EasyAccessConnectionException("Error connecting to easy access...", e);
            }
        }