private void Button_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(TokenInputBox.Text)) { MessageBox.Show("No token"); } else { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://api.github.com"); var token = TokenInputBox.Text; var service = new GitService(token); if (service.AuthenticateUser(token)) { Home home = new Home(token); home.Show(); this.Close(); } else { MessageBox.Show("Bad Token"); } } }