Cannot download recording

include "vendor/autoload.php";
use \Firebase\JWT\JWT;
$key = "*********";
$payload = array(
"iss" => "******",
"exp" => time()+36000,
);

$jwt = JWT::encode($payload, $key, 'HS256'); 

$curl = curl_init();
$d = "https://us02web.zoom.us/rec/download/ABCDEFGH?access_token=".$jwt;
curl_setopt_array($curl, array(
  CURLOPT_URL =>  $d,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTPHEADER => array(
"authorization: Bearer {$jwt}",
"content-type: application/json"
  ),  ));

$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

This script works well with zoom api. I can read anything I need. But when I try to download file by download_link, using JWT token (as in script). I get

{"status":false,"errorCode":401,"errorMessage":"Forbidden"} message

What I do wrong? Thank you.

1 Like

Hey @karasiov,

Please try removing your authorization bearer header, and only use the ?access_token=jwt method of authentication.

Thanks,
Tommy

I did it, thank you very much!

below is example which worked for me:

Summary
<?    
include "vendor/autoload.php";    
use \Firebase\JWT\JWT;    
$payload = array(    
    "iss" => API_KEY,    
    "exp" => time()+36000,     
);    
$jwt = JWT::encode($payload, API_SECRET, 'HS256');    
$url = "https://us02web.zoom.us/rec/download/ABCDEFGH?access_token=".$jwt;    
get_file($url);    
function get_file($url){    
  $f = fopen("file.mp4", "w");    
  $curl = curl_init();    
  curl_setopt_array($curl, array(    
  CURLOPT_URL =>  $url,    
  CURLOPT_RETURNTRANSFER => true,    
  CURLOPT_ENCODING => "",    
  CURLOPT_MAXREDIRS => 10,    
  CURLOPT_TIMEOUT => 600, //!!! Do not forget about file size    
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,    
  CURLOPT_CUSTOMREQUEST => "GET",    
  CURLOPT_FOLLOWLOCATION => true,    
  CURLOPT_FILE => $f));    
$response = curl_exec($curl);    
$err = curl_error($curl);    
curl_close($curl);    
    
if ($err) {    
  echo "cURL Error #:" . $err;
 exit();    
}    
fclose($f);    
}

Happy to hear that fixed it! :slight_smile:

Thanks,
Tommy