• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/oauthservice.php
  • Класс: BitrixRestOAuthService
  • Вызов: OAuthService::register
static function register()
{
	$httpClient = new HttpClient();

	$queryParams = array(
		"redirect_uri" => static::getRedirectUri(),
		"type" => static::CLIENT_TYPE,
	);

	$memberId = CRestUtil::getMemberId();
	if($memberId !== null)
	{
		$queryParams["member_id"] = $memberId;
	}

	$queryParams = CRestUtil::signLicenseRequest($queryParams, static::getEngine()->getLicense());

	$httpResult = $httpClient->post(static::SERVICE_URL.static::REGISTER, $queryParams);

	try
	{
		$result = Json::decode($httpResult);
	}
	catch(ArgumentException $e)
	{
		$result = array(
			"error" => "Wrong answer from service: ".$httpResult,
		);
	}

	if($result["error"])
	{
		throw new SystemException($result["error"]);
	}
	else
	{
		static::getEngine()->setAccess($result);
	}
}