//private void btnModifyApp_Click(object sender, EventArgs e) //{ // string clientId = ((AzureApp)listApps.SelectedItem).ClientId; // AppsEdit formEdit = new AppsEdit(clientId); // ShowFormBeside(this, formEdit); //} private void btnDelegateToken_Click(object sender, EventArgs e) { string clientId = ((AzureApp)listApps.SelectedItem).ClientId; AzureApp app = dataService.GetApp(clientId); TokenRequest tokenRequest = new TokenRequest(app, lstResrouce.Text, lstUsers.Text); TokenRequestHelp tokenRequestHelp = new TokenRequestHelp(tokenRequest); tokenRequestHelp.Send("https://login.microsoftonline.com"); dataService.SaveApp(app); RefreshTokenControlUI(); MessageBox.Show(tokenRequest.AccessToken); }
public AppsEdit(string clientId) { InitializeComponent(); AzureApp app = dataService.GetApp(clientId); comboType.DataSource = Enum.GetValues(typeof(AzureAppType)).Cast <AzureAppType>(); txtAppName.Text = app.AppName; txtClientId.Text = app.ClientId; txtRedirectURL.Text = app.RedirectURL; if (app.Type == AzureAppType.client) { lblSecret.Visible = false; txtSecret.Visible = false; comboType.SelectedItem = AzureAppType.client; } else { comboType.SelectedItem = AzureAppType.Server; txtSecret.Text = ((ServerAzureApp)app).Secret; } }
private void RefreshTokenControlUI() { try { dataService = getDbContext(); var appId = ((AzureApp)listApps.SelectedItem).ClientId; var app = dataService.GetApp(appId); var tokenRequestIndex = app.tokenRequests.FindIndex(tokekRequest => (tokekRequest.Resource == lstResrouce.Text && tokekRequest.SignInUserName == lstUsers.Text)); if (tokenRequestIndex != -1) { txtAccessToken.Text = app.tokenRequests[tokenRequestIndex].AccessToken; txtRefreshToken.Text = app.tokenRequests[tokenRequestIndex].RefreshToken; } else { txtAccessToken.Text = ""; txtRefreshToken.Text = ""; } } catch (Exception ex) { } }