Microsoft 365 PHP Scripts - mix of testing and work in progress.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
m365-php/m365-secalerts.php

29 lines
783 B

<?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);
?>