Add Graph API client integration to entra class

Introduce methods to initialize a GraphServiceClient and ClientCredentialContext, leveraging configuration values for authentication. This enables interaction with Microsoft Graph API in a structured and secure manner.
This commit is contained in:
Jepp9350
2025-05-21 14:44:39 +02:00
parent 458e2916a6
commit bf68432484
+16
View File
@@ -5,6 +5,8 @@ namespace classes;
require_once WD . '/modules/entra/entra_c.php';
use entra\entra_c;
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext;
class entra
{
@@ -18,4 +20,18 @@ class entra
{
$this->config = new entra_c();
}
public function getGraphClient(): GraphServiceClient
{
return new GraphServiceClient($this->getTokenRequestContext());
}
public function getTokenRequestContext(): ClientCredentialContext
{
return new ClientCredentialContext(
$this->config->tenant_id->getVariableValue(),
$this->config->client_id->getVariableValue(),
$this->config->client_secret->getVariableValue()
);
}
}