• Модуль: mail
  • Путь к файлу: ~/bitrix/modules/mail/lib/helper/oauth.php
  • Класс: BitrixMailHelperOAuth
  • Вызов: OAuth::getSocservToken
static function getSocservToken($service, $key)
{
	if (MainLoader::includeModule('socialservices'))
	{
		switch ($service)
		{
			case 'google':
				$oauthClient = new CSocServGoogleOAuth($key);
				$oauthClient->getEntityOAuth()->addScope('https://mail.google.com/');
				break;
			case 'liveid':
				$oauthClient = new CSocServLiveIDOAuth($key);
				$oauthClient->getEntityOAuth()->addScope(['wl.imap', 'wl.offline_access']);
				break;
		}

		if (!empty($oauthClient))
		{
			return $oauthClient->getStorageToken() ?: false;
		}
	}

	return null;
}