Invalid Client on Refresh Token

I am unable to get a refrsh token. It says invalid client.

$client_id = ‘’;
$client_secret = ‘’;
$old_token = ‘’;
$authorization = "Basic " + base64_encode($client_id + ‘:’ + $client_secret);

//extract data from the post
//set POST variables
$url = ‘https://api.infusionsoft.com/token’;
$fields = array(
‘grant_type’=>‘refresh_token’,
‘refresh_token’=>$old_token,
);

//url-ify the data for the POST
$fields_string = ‘’;
foreach($fields as $key=>$value) { $fields_string .= $key.‘=’.$value.‘&’; }
rtrim($fields_string, ‘&’);

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/x-www-form-urlencoded’, ‘Authorization: $authorization’));
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$tokendata = curl_exec($ch);

//close connection
curl_close($ch);

Once you request a refresh BOTH the access and refresh tokens you have become invalid and you must REPLACE them with the new. You cannot re-use previously used refresh tokens. They are invalid the moment you get a new set. You must maintain them in a database and cycle them out once used. The access token is good for 24 hours so to maintain them you must run a refresh with the refresh token before it expires or at least use the refresh token before it expires in 90 days (might be six months now?).