• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/document/office365handler.php
  • Класс: BitrixDiskDocumentOffice365Handler
  • Вызов: Office365Handler::checkHttpResponse
public function checkHttpResponse(HttpClient $http)
{
	$status = (int)$http->getStatus();
	if($status === 404)
	{
		$result = Json::decode($http->getResult());
		if (!empty($result['error']['code']) && $result['error']['code'] === 'itemNotFound')
		{
			//it's hack. Because this type of error we will get when user has lack of scopes (old version scopes).
			$this->errorCollection[] = new Error(
				'Insufficient scope (403)',
				self::ERROR_CODE_INSUFFICIENT_SCOPE
			);

			return false;
		}
	}
	elseif($status === 400)
	{
		$result = Json::decode($http->getResult());
		$code = $result['error']['code'] ?? null;
		$message = $result['error']['message'] ?? null;

		if (
			$code === 'invalidRequest'
			&& $message === 'The default link settings cannot be used to create a sharing link without a scope. Scope must be specified'
		)
		{
			//shared link doesn't work due to policy https://go.microsoft.com/fwlink/?linkid=2185222
			if (!$this->errorCollection->getErrorByCode(self::ERROR_CODE_SHARED_LINK_RESTRICTIONS))
			{
				$this->errorCollection[] = new Error(
					Loc::getMessage('DISK_OFFICE365_HANDLER_ERROR_COULD_NOT_GET_SHARED_LINK'),
					self::ERROR_CODE_SHARED_LINK_RESTRICTIONS
				);
			}

			return false;
		}
	}

	return parent::checkHttpResponse($http);
}