- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/document/googlehandler.php
- Класс: BitrixDiskDocumentGoogleHandler
- Вызов: GoogleHandler::checkHttpResponse
public function checkHttpResponse(HttpClient $http)
{
$status = (int)$http->getStatus();
if($status === 401)
{
$this->errorCollection[] = new Error(
'Invalid credentials (401)', self::ERROR_CODE_INVALID_CREDENTIALS
);
}
elseif($status === 403)
{
$headers = $http->getHeaders();
$response = $http->getResult();
$errorMessage = 'Unknown error';
if($response && is_string($response))
{
$jsonResponse = Json::decode($response);
if(isset($jsonResponse['error']['message']))
{
$errorMessage = $jsonResponse['error']['message'];
}
unset($jsonResponse, $response);
}
$headerAuthenticate = $headers->get('WWW-Authenticate');
if(is_string($headerAuthenticate) && mb_strpos($headerAuthenticate, 'insufficient') !== false)
{
$this->errorCollection[] = new Error(
'Insufficient scope (403)', self::ERROR_CODE_INSUFFICIENT_SCOPE
);
return false;
}
elseif(mb_strpos($errorMessage, 'The authenticated user has not installed the app with client') !== false)
{
$this->errorCollection[] = new Error(
'The authenticated user has not installed the app (403)', self::ERROR_CODE_NOT_INSTALLED_APP
);
}
elseif(mb_strpos($errorMessage, 'The authenticated user has not granted the app') !== false)
{
$this->errorCollection[] = new Error(
'The authenticated user has not granted the app (403)', self::ERROR_CODE_NOT_GRANTED_APP
);
}
elseif(mb_strpos($errorMessage, 'Invalid accessLevel') !== false)
{
$this->errorCollection[] = new Error(
'Invalid accessLevel (403)', self::ERROR_CODE_INVALID_ACCESS_LEVEL
);
}
elseif(mb_strpos($errorMessage, 'is not properly configured as a Google Drive app') !== false)
{
$this->errorCollection[] = new Error(
'The app does not exist or is not properly configured as a Google Drive app (403)', self::ERROR_CODE_APP_NOT_CONFIGURED
);
}
elseif(mb_strpos($errorMessage, 'is blacklisted') !== false)
{
$this->errorCollection[] = new Error(
'The app is blacklisted as a Google Drive app. (403)', self::ERROR_CODE_APP_IN_BLACKLIST
);
}
elseif($errorMessage)
{
$this->errorCollection[] = new Error(
$errorMessage, self::ERROR_CODE_UNKNOWN
);
}
}
if($this->errorCollection->hasErrors())
{
return false;
}
return parent::checkHttpResponse($http);
}