• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/google/manager.php
  • Класс: BitrixCalendarSyncGoogleManager
  • Вызов: Manager::initHttpClient
private function initHttpClient(bool $force = false): bool
{
	$success = true;
	$userId = $this->userId;
	if (!isset(self::$httpClients[$userId]) || $force)
	{
		if (!Loader::includeModule('socialservices'))
		{
			throw new SystemException('Module Socialservices not found');
		}

		$httpClient = new HttpClient();
		$oAuthEntity = $this->prepareAuthEntity($userId);

		if ($oAuthEntity->getToken())
		{
			$httpClient->setHeader('Authorization', 'Bearer ' . $oAuthEntity->getToken());
			$httpClient->setHeader('Content-Type', 'application/json');
			$httpClient->setHeader('Referer', BitrixCalendarSyncUtilHelper::getDomain());
			unset($oAuthEntity);
		}
		else
		{
			$success = false;
		}

		self::$httpClients[$userId] = new HttpQuery($httpClient, $userId);
	}

	$this->httpClient = self::$httpClients[$userId];

	return $success;
}