- Модуль: socialservices
- Путь к файлу: ~/bitrix/modules/socialservices/classes/general/bitrix24.php
- Класс: CSocServBitrixOAuth
- Вызов: CSocServBitrixOAuth::Authorize
public function Authorize()
{
global $APPLICATION;
$APPLICATION->RestartBuffer();
if((isset($_REQUEST["code"]) && $_REQUEST["code"] <> '') && CSocServAuthManager::CheckUniqueKey())
{
$redirect_uri = CHTTP::URN2URI('/bitrix/tools/oauth/bitrix24.php');
$userId = intval($_REQUEST['uid']);
$appID = trim(COption::GetOptionString("socialservices", "bitrix24_gadget_appid", ''));
$appSecret = trim(COption::GetOptionString("socialservices", "bitrix24_gadget_appsecret", ''));
$portalURI = $_REQUEST['domain'];
if(mb_strpos($portalURI, "http://") === false && mb_strpos($portalURI, "https://") === false)
$portalURI = "https://".$portalURI;
$gAuth = new CBitrixOAuthInterface($appID, $appSecret, $portalURI, $_REQUEST["code"]);
$this->entityOAuth = $gAuth;
$gAuth->addScope(explode(',', $_REQUEST["scope"]));
if($gAuth->GetAccessToken($redirect_uri) !== false)
{
$gAuth->saveDataDB();
}
}
$url = CHTTP::URN2URI(BX_ROOT);
$mode = 'opener';
$url = CUtil::JSEscape($url);
$location = ($mode == "opener") ? 'if(window.opener) window.opener.location = ''.$url.''; window.close();' : ' window.location = ''.$url.'';';
$JSScript = '
';
echo $JSScript;
CMain::FinalActions();
}