public async Task Login(string username, string password)
        {
            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://api.robinhood.com/");
                var request = new HttpRequestMessage(HttpMethod.Post, "api-token-auth/");
                client.DefaultRequestHeaders.Add("Accept", "*/*");
                client.DefaultRequestHeaders.Add("Accept-Language", "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5");
                client.DefaultRequestHeaders.Add("X-Robinhood-API-Version", "1.0.0");
                client.DefaultRequestHeaders.Connection.Add("keep-alive");
                client.DefaultRequestHeaders.Add("User-Agent", "Robinhood/823 (iPhone; iOS 7.1.2; Scale/2.00)");

                List <KeyValuePair <string, string> > data = new List <KeyValuePair <string, string> >();
                data.Add(new KeyValuePair <string, string>("username", username));
                data.Add(new KeyValuePair <string, string>("password", password));

                request.Content = new FormUrlEncodedContent(data);
                HttpResponseMessage response = await client.SendAsync(request);

                string loginResponse = await response.Content.ReadAsStringAsync();

                try
                {
                    ApiTokenAuth auth = JsonConvert.DeserializeObject <ApiTokenAuth>(loginResponse);
                    token = auth.token;
                }
                catch
                {
                    throw new ConnectionException(loginResponse);
                }

                if (response.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    throw new ConnectionException(loginResponse);
                }

                if (token != null)
                {
                    this.ConnectionEstablished(this, null);
                }
                else
                {
                    throw new ConnectionException(loginResponse);
                }
            }
        }
        public async void Login(string username, string password)
        {
            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://api.robinhood.com/");
                var request = new HttpRequestMessage(HttpMethod.Post, "api-token-auth/");
                client.DefaultRequestHeaders.Add("Accept", "*/*");
                client.DefaultRequestHeaders.Add("Accept-Language", "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5");
                client.DefaultRequestHeaders.Add("X-Robinhood-API-Version", "1.0.0");
                client.DefaultRequestHeaders.Connection.Add("keep-alive");
                client.DefaultRequestHeaders.Add("User-Agent", "Robinhood/823 (iPhone; iOS 7.1.2; Scale/2.00)");

                List <KeyValuePair <string, string> > data = new List <KeyValuePair <string, string> >();
                data.Add(new KeyValuePair <string, string>("username", username));
                data.Add(new KeyValuePair <string, string>("password", password));

                request.Content = new FormUrlEncodedContent(data);
                HttpResponseMessage response = await client.SendAsync(request);

                String responseContent = await response.Content.ReadAsStringAsync();


                try
                {
                    var jss = new JavaScriptSerializer();

                    ApiTokenAuth auth = jss.Deserialize <ApiTokenAuth>(responseContent);

                    token = auth.token;


                    Console.WriteLine(token);
                    lblStatus.Content = "Logged in!";
                }
                catch
                {
                    MessageBox.Show("Problem logging in: " + responseContent);
                }
            }
        }