Skip to content

Commit

Permalink
Merge pull request kaltura#11319 from kaltura/Quasar-17.17.0-SUP-30033
Browse files Browse the repository at this point in the history
Quasar 17.17.0 sup 30033
  • Loading branch information
salma2222 authored Dec 30, 2021
2 parents cd670fd + 7a819f5 commit 464700b
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ protected function initZoomClient(KalturaDropFolder $dropFolder)
$clientId = isset($dropFolder->clientId) ? $dropFolder->clientId : null;
$clientSecret = isset($dropFolder->clientSecret) ? $dropFolder->clientSecret : null;
$accessToken = isset($dropFolder->accessToken) ? $dropFolder->accessToken : null;
return new kZoomClient($dropFolder->baseURL, $jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken);
$accessExpiresIn = isset($dropFolder->accessExpiresIn) ? $dropFolder->accessExpiresIn : null;
return new kZoomClient($dropFolder->baseURL, $jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken, $accessExpiresIn);
}

protected function getMeetingsInStartTimeOrder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public function __construct($zoomBaseUrl, KalturaZoomDropFolder $folder)
$clientId = isset($folder->clientId) ? $folder->clientId : null;
$clientSecret = isset($folder->clientSecret) ? $folder->clientSecret : null;
$accessToken = isset($folder->accessToken) ? $folder->accessToken : null;
$this->zoomClient = new kZoomClient($zoomBaseUrl, $jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken);
$accessExpiresIn = isset($folder->accessExpiresIn) ? $folder->accessExpiresIn : null;
$this->zoomClient = new kZoomClient($zoomBaseUrl, $jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken, $accessExpiresIn);
$this->dropFolder = $folder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ class KalturaZoomDropFolder extends KalturaDropFolder
* @readonly
*/
public $accessToken;

/**
* @readonly
*/
public $accessExpiresIn;

/**
* @readonly
*/
public $clientId;
Expand Down Expand Up @@ -87,9 +92,10 @@ public function doFromObject($sourceObject, KalturaDetachedResponseProfile $resp
$this -> jwtToken = $vendorIntegration -> getJwtToken();
$this -> refreshToken = $vendorIntegration -> getRefreshToken();
$this -> accessToken = $vendorIntegration -> getAccessToken();
$this -> accessExpiresIn = $vendorIntegration -> getExpiresIn();
$this -> description = $vendorIntegration->getZoomAccountDescription();
$zoomClient = new kZoomClient($this -> baseURL, $this -> jwtToken, $this -> refreshToken, $this -> clientId,
$this -> clientSecret, $this -> accessToken);
$this -> clientSecret, $this -> accessToken, $this -> accessExpiresIn);

if ($this -> accessToken && $this -> refreshToken && kCurrentContext ::$ks_partner_id == Partner::BATCH_PARTNER_ID &&
$vendorIntegration -> getExpiresIn() <= time() +
Expand All @@ -101,6 +107,7 @@ public function doFromObject($sourceObject, KalturaDetachedResponseProfile $resp
{
$this -> accessToken = $freshTokens[kZoomTokens::ACCESS_TOKEN];
$this -> refreshToken = $freshTokens[kZoomTokens::REFRESH_TOKEN];
$this -> accessExpiresIn = $freshTokens[kZoomTokens::EXPIRES_IN];
$vendorIntegration -> saveTokensData($freshTokens);
}
}
Expand Down
10 changes: 7 additions & 3 deletions plugins/vendor/zoom/infra/kZoomClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class kZoomClient
protected $zoomBaseURL;
protected $refreshToken;
protected $accessToken;
protected $accessExpiresIn;
protected $jwtToken;
protected $clientId;
protected $clientSecret;
Expand All @@ -35,11 +36,12 @@ class kZoomClient
* @param null $refreshToken
* @param null $clientId
* @param null $clientSecret
* @param null $accessToken
* @param null $accessToken
* @param null $accessExpiresIn
* @throws KalturaAPIException
*/
public function __construct($zoomBaseURL, $jwtToken = null, $refreshToken = null, $clientId = null,
$clientSecret= null, $accessToken = null)
$clientSecret= null, $accessToken = null, $accessExpiresIn = null)
{
$this -> zoomBaseURL = $zoomBaseURL;
// check if at least one is available, otherwise throw exception
Expand All @@ -52,6 +54,7 @@ public function __construct($zoomBaseURL, $jwtToken = null, $refreshToken = null
$this->clientId = $clientId;
$this->clientSecret = $clientSecret;
$this->accessToken = $accessToken;
$this->accessExpiresIn = $accessExpiresIn;
$this->zoomTokensHelper = new kZoomTokens($zoomBaseURL, $clientId, $clientSecret);
}

Expand Down Expand Up @@ -258,7 +261,7 @@ protected function generateContextualUrl($apiPath)
$url = $this -> zoomBaseURL . $apiPath . '?';
if ($this->refreshToken)
{
if (!$this->accessToken)
if (!$this->accessToken || ($this->accessExpiresIn && $this->accessExpiresIn <= time()))
{
$this->refreshTokens();
}
Expand All @@ -274,6 +277,7 @@ public function refreshTokens()
$tokens = $this -> zoomTokensHelper -> refreshTokens($this -> refreshToken);
$this -> accessToken = $tokens[kZoomTokens::ACCESS_TOKEN];
$this -> refreshToken = $tokens[kZoomTokens::REFRESH_TOKEN];
$this -> accessExpiresIn = $tokens[kZoomTokens::EXPIRES_IN];
}
return $tokens;

Expand Down
12 changes: 1 addition & 11 deletions plugins/vendor/zoom/infra/kZoomTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,7 @@ public function __construct($zoomBaseURL, $clientId, $clientSecret)
$this->clientId = $clientId;
$this->clientSecret = $clientSecret;
}

public function generateAccessToken($refreshToken)
{
KalturaLog::debug('Refreshing access token from token ' . $refreshToken);
$postFields = "grant_type=refresh_token&refresh_token=$refreshToken";
$response = $this->curlRetrieveTokensData($postFields);
$tokensData = $this->parseTokensResponse($response);
KalturaLog::debug('New tokens response' . print_r($tokensData, true));
return $tokensData[self::ACCESS_TOKEN];
}


public function refreshTokens($oldRefreshToken)
{
KalturaLog::info('Refreshing Zoom Tokens');
Expand Down
5 changes: 3 additions & 2 deletions plugins/vendor/zoom/lib/model/kZoomEventHanlder.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function processEvent($event)
$transcriptProcessor = new kZoomTranscriptProcessor($this->zoomConfiguration[kZoomClient::ZOOM_BASE_URL],
$zoomVendorIntegration->getJwtToken(),
$zoomVendorIntegration->getRefreshToken(),
null, null, $zoomVendorIntegration->getAccessToken());
null, null, $zoomVendorIntegration->getAccessToken(), $zoomVendorIntegration->getExpiresIn());
$transcriptProcessor->handleRecordingTranscriptComplete($event);
}
break;
Expand All @@ -97,11 +97,12 @@ protected function initZoomClient(ZoomVendorIntegration $zoomVendorIntegration)
$jwtToken = $zoomVendorIntegration->getJwtToken();
$refreshToken = $zoomVendorIntegration->getRefreshToken();
$accessToken = $zoomVendorIntegration->getAccessToken();
$accessExpiresIn = $zoomVendorIntegration->getExpiresIn();
$zoomConfiguration = kConf::get(self::CONFIGURATION_PARAM_NAME, self::MAP_NAME);
$clientId = $zoomConfiguration['clientId'];
$zoomBaseURL = $zoomConfiguration['ZoomBaseUrl'];
$clientSecret = $zoomConfiguration['clientSecret'];
return new kZoomClient($zoomBaseURL, $jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken);
return new kZoomClient($zoomBaseURL, $jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken, $accessExpiresIn);
}


Expand Down
7 changes: 4 additions & 3 deletions plugins/vendor/zoom/lib/model/processors/kZoomProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ abstract class kZoomProcessor
* @param string $refreshToken
* @param string $clientId
* @param string $clientSecret
* @param string $accessToken
* @param string $accessToken
* @param string $accessExpiresIn
*/
public function __construct($zoomBaseUrl,$jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken)
public function __construct($zoomBaseUrl,$jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken, $accessExpiresIn)
{
$this->zoomClient = new kZoomClient($zoomBaseUrl, $jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken);
$this->zoomClient = new kZoomClient($zoomBaseUrl, $jwtToken, $refreshToken, $clientId, $clientSecret, $accessToken, $accessExpiresIn);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct($zoomBaseUrl)
$this->zoomBaseUrl = $zoomBaseUrl;
$this->zoomIntegration = ZoomHelper::getZoomIntegration();
parent::__construct($zoomBaseUrl, $this->zoomIntegration->getJwtToken(), $this->zoomIntegration->getRefreshToken(), null, null,
$this->zoomIntegration->getAccessToken());
$this->zoomIntegration->getAccessToken(), $this->zoomIntegration->getExpiresIn());
}

/**
Expand Down Expand Up @@ -88,8 +88,8 @@ public function handleRecordingVideoComplete($event)

if (isset($recordingFilesPerTimeSlot[kRecordingFileType::CHAT]))
{
$chatFilesProcessor = new kZoomChatFilesProcessor($this->zoomBaseUrl, $this->zoomIntegration->getJwtToken(),
$this->zoomIntegration->getRefreshToken(), null, null, $this->zoomIntegration->getAccessToken());
$chatFilesProcessor = new kZoomChatFilesProcessor($this->zoomBaseUrl, $this->zoomIntegration->getJwtToken(), $this->zoomIntegration->getRefreshToken(),
null, null, $this->zoomIntegration->getAccessToken(), $this->zoomIntegration->getExpiresIn());

foreach($recordingFilesPerTimeSlot[kRecordingFileType::CHAT] as $recordingFile)
{
Expand Down
7 changes: 4 additions & 3 deletions plugins/vendor/zoom/services/ZoomVendorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public function preOauthValidation()
$authCode = $_GET[self::AUTH_CODE];
$tokens = kZoomOauth::requestAccessToken($authCode);
$accessToken = $tokens[kZoomOauth::ACCESS_TOKEN];
$client = new kZoomClient($zoomBaseURL, null, null, null, null, $accessToken );
$accessExpiresIn = $tokens[kZoomOauth::EXPIRES_IN];
$client = new kZoomClient($zoomBaseURL, null, null, null, null, $accessToken, $accessExpiresIn);
$permissions = $client->retrieveTokenZoomUserPermissions();
$user = $client->retrieveTokenZoomUser();
$accountId = $user[ZoomHelper::ACCOUNT_ID];
Expand Down Expand Up @@ -184,7 +185,7 @@ public function fetchRegistrationPageAction($tokensData, $iv)
$zoomConfiguration = self::getZoomConfiguration();
$tokens = $this->handleEncryptTokens($tokensData, $iv, $zoomConfiguration);
$zoomBaseURL = $zoomConfiguration[kZoomClient::ZOOM_BASE_URL];
$client = new kZoomClient($zoomBaseURL,null,$tokens[kZoomTokens::REFRESH_TOKEN],null,null,$tokens[kZoomTokens::ACCESS_TOKEN]);
$client = new kZoomClient($zoomBaseURL, null, $tokens[kZoomTokens::REFRESH_TOKEN], null, null, $tokens[kZoomTokens::ACCESS_TOKEN], $tokens[kZoomTokens::EXPIRES_IN]);
$accountId = $this->getAccountId($client->retrieveTokenZoomUser());
$zoomIntegration = ZoomHelper::getZoomIntegrationByAccountId($accountId, true);
$partnerId = kCurrentContext::getCurrentPartnerId();
Expand Down Expand Up @@ -216,7 +217,7 @@ public function localRegistrationPageAction($jwt)
}
$zoomConfiguration = self::getZoomConfiguration();
$zoomBaseURL = $zoomConfiguration[kZoomClient::ZOOM_BASE_URL];
$client = new kZoomClient($zoomBaseURL,$jwt,null,null,null,null);
$client = new kZoomClient($zoomBaseURL, $jwt, null, null, null, null, null);
$zoomAccountId = $this->getAccountId($client->retrieveTokenZoomUser());
$zoomIntegration = ZoomHelper::getZoomIntegrationByAccountId($zoomAccountId);
if(!$zoomIntegration)
Expand Down

0 comments on commit 464700b

Please sign in to comment.