private async void uxComboBoxAccounts_SelectedIndexChanged(object sender, EventArgs e) { if (uxComboBoxAccounts.SelectedItem is string) { MessageBox.Show(AddDomainHintInstructions, Utils.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); uxComboBoxAccounts.SelectedItem = null; return; } _currentAccountItem = (AccountItem)uxComboBoxAccounts.SelectedItem; if (null == _currentAccountItem) { return; } using (var op = NewUxOperationWithProgress(uxComboBoxAccounts)) { var vaui = new VaultAccessUserInteractive(_currentAccountItem.DomainHint); _currentAuthResult = vaui.AcquireToken(_currentAccountItem.AuthContext, ManagmentEndpoint); _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(_currentAuthResult.AccessTokenType, _currentAuthResult.AccessToken); var hrm = await _httpClient.GetAsync($"{ManagmentEndpoint}subscriptions?{ApiVersion}", op.CancellationToken); var json = await hrm.Content.ReadAsStringAsync(); var subs = JsonConvert.DeserializeObject <SubscriptionsResponse>(json); uxListViewSubscriptions.Items.Clear(); uxListViewVaults.Items.Clear(); uxPropertyGridVault.SelectedObject = null; foreach (var s in subs.Subscriptions) { uxListViewSubscriptions.Items.Add(new ListViewItemSubscription(s)); } } }
// Attempt to authenticate with current account. private void GetAuthenticationToken() { VaultAccessUserInteractive vaui = new VaultAccessUserInteractive(_currentAccountItem.DomainHint, _currentAccountItem.UserAlias); _currentAuthResult = vaui.AcquireToken(_currentAccountItem.AuthContext, ManagmentEndpoint, _currentAccountItem.UserAlias); }