• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_sync.php
  • Класс: CCalendarSync
  • Вызов: CCalendarSync::GetOffice365AuthLink
static function GetOffice365AuthLink($userId, $type): string
{
	$isCaldavEnabled = CCalendar::IsCalDAVEnabled() && $type === 'user';
	$isOfficeApiEnabled = CCalendar::isOffice365ApiEnabled() && $type === 'user';
	$officeApiLink = '';

	if ($isOfficeApiEnabled && $isCaldavEnabled)
	{
		$curPath = '#office365AuthSuccess';

		$client = new CSocServOffice365OAuth($userId);

		/** @var SyncOffice365Helper $helper */
		$helper = ServiceLocator::getInstance()->get('calendar.service.office365.helper');
		$client->getEntityOAuth()->addScope($helper::NEED_SCOPE);

		return $client->getUrl(
			'opener',
			null,
			[
				'BACKURL' => $curPath,
			],
		);
	}

	return $officeApiLink;
}