private static string GetAuthorizationHeader() { var config = AcmSettings.Load(); AuthenticationResult result = null; var context = new AuthenticationContext(string.Format( config.Login, config.TenantId)); var thread = new Thread(() => { result = context.AcquireToken( config.ApiEndpoint, config.ClientId, new Uri(config.RedirectUri)); }); thread.SetApartmentState(ApartmentState.STA); thread.Name = "AquireTokenThread"; thread.Start(); thread.Join(); if (result == null) { throw new InvalidOperationException("Failed to obtain the JWT token"); } return(result.AccessToken); }
private void LoadSubscriptions() { var config = AcmSettings.Load(); comboSubscription.Items.Clear(); foreach (var sub in config.Subscriptions.OrderBy(s => s.Value)) { comboSubscription.Items.Add($"{sub.Value}={sub.Key}"); } }
private void LoadSettings(AcmSettings settings) { txtLogin.Text = settings.Login; txtTenantId.Text = settings.TenantId; txtApiEndpoint.Text = settings.ApiEndpoint; txtClientId.Text = settings.ClientId; txtRedirectUri.Text = settings.RedirectUri; txtFileZillaLocation.Text = settings.FileZillaLocation; DataGridHelpers.FillDataGridFromDictionary(gridSubscriptions, settings.Subscriptions); }
private void btnFilezilla_Click(object sender, EventArgs e) { if (_currentApp == null) { return; } var fileZillaLocation = AcmSettings.Load().FileZillaLocation; Process.Start(fileZillaLocation, _currentApp.FtpSettings.FilezillaArgument); }
private void SaveSettings() { var settings = new AcmSettings { Login = txtLogin.Text, TenantId = txtTenantId.Text, ApiEndpoint = txtApiEndpoint.Text, ClientId = txtClientId.Text, RedirectUri = txtRedirectUri.Text, Subscriptions = DataGridHelpers.DataGridToDictionary(gridSubscriptions), FileZillaLocation = txtFileZillaLocation.Text }; AcmSettings.Save(settings); }
private void Settings_Load(object sender, EventArgs e) { LoadSettings(AcmSettings.Load()); }