Refresh token missing zoho v2 api

Many people spend hours and hours to get the refresh token when authorizing their app using zoho v2 api.

Here are our tip to get it quick.

screencapture-accounts-zoho-oauth-v2-auth-2020-09-22-21_41_41

When you are on this screen. Don’t forget to make access_type=offline in the URL.

Then get the code. And use the below code to get the json of access token and refresh token.

$ch = curl_init();
$data = array("code" =>$code,"redirect_uri"=>$redirect_url, "client_id"=>$client_id, "client_secret" =>$client_secret, "grant_type"=> "authorization_code");
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);