Getting intermittent 401 errors retrieving new access token

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;

}

Hey @greg.ross,

Thank you for reaching out to the Zoom Developer Forum. First, It’s important to note that the refresh_token will only work for the currently access_token. If a new access_token is requested separately then this will invalidate the refresh_token that you have.

If that isn’t helpful, are you able to provide the full response body that you’re seeing when you encounter this issue?

Thanks,
Max

Thank you.
I use the existing fresh token to get a new access token before using it and then save the new refresh token for another time. The same code works consistently for many api requests. I will change the code so it provides a full response body upon error.

Hey @greg.ross,

Thank you for the update. I’ll advise further when we have the request body to review.

Thanks,
Max

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.