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