Description
Various users of our private OAuth app are getting intermittent errors when the app tries to retrieve a new access token using a stored refresh token.
Error
Could not retrieve access token. Error: 401
PHP Code below.
// $ID=client ID, $Scret = Client Secret, $rtoken = refresh token
function newAccToken($ID, $Secret, $rtoken)
{
$b64idsec = base64_encode($ID.":".$Secret);
$header = array(“Authorization: Basic {$b64idsec}”);
$curl = curl_init();
$url = “https://zoom.us/oauth/token”;
$content=“grant_type=refresh_token&refresh_token={$rtoken}”;
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $content,
CURLOPT_HTTPHEADER => $header
));
$response = curl_exec($curl);
$ret['response_code']=curl_getinfo($curl, CURLINFO_RESPONSE_CODE); // code > 200 error
$ret['response']=$response;
curl_close($curl);
return $ret;
}