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:
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user