• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/classes/general/rest_provider.php
  • Класс: CRestProvider
  • Вызов: CRestProvider::getApp
static function getApp(CRestServer $server)
{
	if(self::$arApp == null)
	{
		if(CModule::IncludeModule('oauth'))
		{
			$client = OAuthBase::instance($server->getClientId());

			if($client)
			{
				self::$arApp = $client->getClient();

				if(is_array(self::$arApp) && is_array(self::$arApp['SCOPE']))
				{
					self::$arApp['SCOPE'] = implode(',', self::$arApp['SCOPE']);
				}
			}
		}
		elseif($server->getClientId())
		{
			self::$arApp = BitrixRestAppTable::getByClientId($server->getClientId());
		}
		else
		{
			throw new AccessException("Application context required");
		}
	}

	return self::$arApp;
}