private async Task <Go> GetApiAsync() { // read per-org power office settings, // fallback to system-wide settings if not set. var appKey = await _organizationSettingsAccessorService .GetOrganizationSettingByNameAsync(PowerOfficeConstants.ApplicationKey) ?? _options.Value.ApplicationKey; var clientKey = await _organizationSettingsAccessorService .GetOrganizationSettingByNameAsync(PowerOfficeConstants.ClientKey) ?? _options.Value.ClientKey; _logger.LogInformation("Using PowerOffice Client with applicationKey: {AppKey}", appKey); return(_api ??= await Go.CreateAsync(new AuthorizationSettings { ApplicationKey = appKey, ClientKey = clientKey, TokenStore = new BasicInMemoryTokenStore(), EndPointHost = new Settings.Host(_options.Value.Mode) })); }
public async Task <ZoomJwtCredentials> GetJwtCredentialsAsync() { var apiKey = await _organizationSettingsAccessorService .GetOrganizationSettingByNameAsync( ZoomConstants.ZoomApiKeySettingKey); var apiSecret = await _organizationSettingsAccessorService .GetOrganizationSettingByNameAsync( ZoomConstants.ZoomApiSecretSettingKey); if (!string.IsNullOrEmpty(apiKey) && !string.IsNullOrEmpty(apiSecret)) { _logger.LogDebug("Using Zoom JWT credentials from organization settings"); return(new ZoomJwtCredentials { Name = "Zoom", ApiKey = apiKey, ApiSecret = apiSecret }); } _logger.LogDebug("Getting Zoom JWT credentials from host-based configuration"); var host = _httpContextAccessor.HttpContext.Request.Host; if (!host.HasValue) { throw new InvalidOperationException("Cannot determine host for request"); } return(_options.Value.Apps?.FirstOrDefault(a => a.Name == host.Value) ?? _options.Value.Apps?.FirstOrDefault(a => a.Name == "*") ?? throw new ZoomConfigurationException($"Zoom config not found for host {host.Value}")); }