-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrosoftGraph.php
55 lines (44 loc) · 1.33 KB
/
MicrosoftGraph.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Class MicrosoftGraph
*
* @created 30.07.2019
* @author smiley <smiley@chillerlan.net>
* @copyright 2019 smiley
* @license MIT
*/
declare(strict_types=1);
namespace chillerlan\OAuth\Providers;
use chillerlan\OAuth\Core\{AuthenticatedUser, UserInfo};
/**
* Microsoft Graph OAuth2
*
* @link https://learn.microsoft.com/en-us/graph/permissions-reference
*/
class MicrosoftGraph extends AzureActiveDirectory implements UserInfo{
public const IDENTIFIER = 'MICROSOFTGRAPH';
public const SCOPE_USER_READ = 'User.Read';
public const SCOPE_USER_READBASIC_ALL = 'User.ReadBasic.All';
public const DEFAULT_SCOPES = [
self::SCOPE_OPENID,
self::SCOPE_OPENID_EMAIL,
self::SCOPE_OPENID_PROFILE,
self::SCOPE_OFFLINE_ACCESS,
self::SCOPE_USER_READ,
self::SCOPE_USER_READBASIC_ALL,
];
protected string $apiURL = 'https://graph.microsoft.com';
protected string|null $apiDocs = 'https://learn.microsoft.com/graph/overview';
/** @codeCoverageIgnore */
public function me():AuthenticatedUser{
$json = $this->getMeResponseData('/v1.0/me');
$userdata = [
'data' => $json,
'handle' => $json['userPrincipalName'],
'displayName' => $json['displayName'],
'email' => $json['mail'],
'id' => $json['id'],
];
return new AuthenticatedUser($userdata);
}
}