• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/office365/office365context.php
  • Класс: BitrixCalendarSyncOffice365Office365Context
  • Вызов: Office365Context::prepareAuthEntity
public function prepareAuthEntity($userId): COffice365OAuthInterface
{
	$oauth = new CSocServOffice365OAuth($userId);
	$oAuthEntity = $oauth->getEntityOAuth();
	$oAuthEntity->addScope($this->helper::NEED_SCOPE);
	$oAuthEntity->setUser($this->owner->getId());
	
	$tokens = $this->getStorageToken($userId);
	if ($tokens)
	{
		$oAuthEntity->setToken($tokens['OATOKEN']);
		$oAuthEntity->setAccessTokenExpires($tokens['OATOKEN_EXPIRES']);
		$oAuthEntity->setRefreshToken($tokens['REFRESH_TOKEN']);
	}
	
	if (!$oAuthEntity->checkAccessToken())
	{
		$oAuthEntity->getNewAccessToken(
			$oAuthEntity->getRefreshToken(),
			$this->owner->getId(),
			true
		);
	}

	return $oAuthEntity;
}