- Модуль: mail
- Путь к файлу: ~/bitrix/modules/mail/lib/helper/oauth/office365.php
- Класс: BitrixMailHelperOAuthOffice365Interface
- Вызов: Office365Interface::refreshWithScopes
private function refreshWithScopes(array $scopes): void
{
if (empty($this->refresh_token))
{
return;
}
$httpClient = new BitrixMainWebHttpClient();
$jsonResponse = $httpClient->post(static::TOKEN_URL, [
'refresh_token' => $this->refresh_token,
'client_id' => $this->appID,
'client_secret' => $this->appSecret,
'grant_type' => 'refresh_token',
'scope' => implode(' ', $scopes),
]);
try
{
$decoded = BitrixMainWebJson::decode($jsonResponse);
if (!empty($decoded['access_token']))
{
$this->access_token = (string)$decoded['access_token'];
$this->refresh_token = (string)$decoded['refresh_token'];
$this->accessTokenExpires = (int)$decoded["expires_in"];
}
}
catch (ArgumentException $e)
{
AddMessage2Log($e->getMessage(), 'mail', 2, true);
}
}