Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/quanthub_core/quanthub_core.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ services:

powerbi_embed_configs:
class: Drupal\quanthub_core\PowerBIEmbedConfigs
arguments: ['@config.factory', '@key.repository', '@logger.factory', '@http_client']
arguments: ['@config.factory', '@logger.factory', '@http_client']

# User Info Cache Context based on User Info Role for anonymous and User Id for others.
cache_context.user_info_attributes:
Expand Down
23 changes: 7 additions & 16 deletions modules/quanthub_core/src/PowerBIEmbedConfigs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\key\KeyRepositoryInterface;
use GuzzleHttp\ClientInterface;
use Jumbojett\OpenIDConnectClient;

Expand All @@ -20,13 +19,6 @@ class PowerBIEmbedConfigs {
*/
protected $configFactory;

/**
* Key repository object.
*
* @var \Drupal\key\KeyRepositoryInterface
*/
protected $repository;

/**
* Logger Factory.
*
Expand All @@ -45,8 +37,6 @@ class PowerBIEmbedConfigs {
* Constructor of PowerBIEmbedConfigs.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The configuration factory service.
* @param \Drupal\key\KeyRepositoryInterface $repository
* The key repository object.
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerFactory
* The logger channel factory.
Expand All @@ -55,12 +45,10 @@ class PowerBIEmbedConfigs {
*/
public function __construct(
ConfigFactoryInterface $configFactory,
KeyRepositoryInterface $repository,
LoggerChannelFactoryInterface $loggerFactory,
ClientInterface $httpClient,
) {
$this->configFactory = $configFactory;
$this->repository = $repository;
$this->loggerFactory = $loggerFactory->get('powerbi_embed');
$this->httpClient = $httpClient;
}
Expand Down Expand Up @@ -97,9 +85,7 @@ public function getUsername() {
* Return PowerBI configured password.
*/
public function getPassword() {
$config_password = $this->getConfig()->get('password');
$key = $this->repository->getKey($config_password);
return $key?->getKeyValue();
return $this->getConfig()->get('password');
}

/**
Expand All @@ -116,7 +102,12 @@ public function getPowerBiAccessToken() {
$oidc->addScope('https://analysis.windows.net/powerbi/api/.default');
$oidc_response = $oidc->requestClientCredentialsToken();
if (empty($oidc_response->access_token)) {
$this->loggerFactory->get('powerbi_embed')->warning('Could not get access token');
$this->loggerFactory->warning(
'Could not get access token @context_error',
[
'@context_error' => print_r($oidc_response, TRUE),
]
);
return NULL;
}
return $oidc_response->access_token;
Expand Down