1
0
Fork 0

Add more examples and tests

master
Brie Bruns 2022-05-31 15:48:54 -06:00
parent fb90683d41
commit 2bd353a054
2 changed files with 29 additions and 1 deletions

29
m365-secalerts.php Normal file
View File

@ -0,0 +1,29 @@
<?php
require_once('vendor/autoload.php');
require_once('config.php');
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
$guzzle = new \GuzzleHttp\Client();
$url = 'https://login.microsoftonline.com/' . $o365TenantId . '/oauth2/v2.0/token';
$token = json_decode($guzzle->post($url, [
'form_params' => [
'client_id' => $clientId,
'client_secret' => $clientSecret,
'scope' => 'https://graph.microsoft.com/.default',
'grant_type' => 'client_credentials',
],
])->getBody()->getContents());
$accessToken = $token->access_token;
$graph = new Graph();
$graph->setAccessToken($accessToken);
$user = $graph->createRequest("GET", "/security/alerts")
->setReturnType(Model\Security::class)
->execute();
print_r($user);
?>

View File

@ -26,5 +26,4 @@ $graph = new Graph();
->setReturnType(Model\User::class) ->setReturnType(Model\User::class)
->execute(); ->execute();
print_r($user); print_r($user);
?> ?>