14 $this->oauthEntity =
new Office365Interface(
15 \CSocServOffice365OAuth::getOption(
'office365_appid'),
16 \CSocServOffice365OAuth::getOption(
'office365_appsecret')
20 $this->oauthEntity->setScope($this->oauthEntity->getGraphScopes());
25 $provider = new \CSocServOffice365OAuth;
27 return $provider->checkSettings();
33 'email' => $userData[
'email'],
34 'first_name' => $userData[
'first_name'],
35 'last_name' => $userData[
'last_name'],
36 'full_name' => $userData[
'name'],
37 'image' => $userData[
'image'],
38 'error' => $userData[
'error_description'],
39 'userPrincipalName' => $userData[
'userPrincipalName'] ??
'',
50 return \CSocServOffice365OAuth::CONTROLLER_URL;
55if (Main\Loader::includeModule(
'socialservices'))
57 class_exists(
'CSocServOffice365OAuth');
59 class Office365Interface
extends \COffice365OAuthInterface
95 'https://outlook.office.com/IMAP.AccessAsUser.All',
96 'https://outlook.office.com/SMTP.Send',
110 $httpClient->setHeader(
"Authorization",
"Bearer " . $this->
access_token);
117 return $decoded[
'userPrincipalName'];
125 catch (ArgumentException
$e)
160 'client_id' => $this->
appID,
162 'grant_type' =>
'refresh_token',
163 'scope' => implode(
' ', $scopes),
176 catch (ArgumentException
$e)
192 'IMAP.AccessAsUser.All',
206 public function getCurrentUser()
216 $httpClient->setHeader(
"Authorization",
"Bearer ". $this->
access_token);
218 $result = $httpClient->get(static::OUTLOOK_RESOURCE . static::OUTLOOK_API_VERSION . static::CONTACTS_URL);
221 $result = \Bitrix\Main\Web\Json::decode($result);
223 catch (ArgumentException
$e)
229 if(
isset($result[
'EmailAddress']))
231 $email = $result[
'EmailAddress'];
232 $emailIsIntended =
false;
237 $email =
$USER->GetEmail();
242 $emailIsIntended =
true;
248 'emailIsIntended' => $emailIsIntended,
249 'userPrincipalName' => $userPrincipalName,
mapUserData(array $userData)