Google App Script AUTH token error message, can you help?

Hello,

So for quite some time now I have been having trouble with my script, the end result of the script is to call data from 2 different data sources using API calls, count the rows and compare them. Everything works the rows are counting for both API calls API call A works perfectly, API CAll B is the problem, when ever it starts counting rows it keeps giving me the AUTH token error message, which I know the auth token is correct, is there a way that I can prevent this from happening, I posted API call’s B code below, it seems the error comes from functions getRecordsByPage(page,perPage,token,module), rowcount() and function propertiesstorage().

function zAuth() {

// post request

var url = “https://accounts.zoho.com/oauth/v2/token”;

//refresh token params

var params =

{

'Token Object

}

//post method for payload

var options =

{

'method': 'post',

'contentType':'application/x-www-form-urlencoded',

'payload': params

}

var response = UrlFetchApp.fetch(url,options);

return JSON.parse(response);

}

function getAccessToken()

{

var token = zAuth().access_token;

return token;

}

function getRecordsByPage(page,perPage,token,module)

{

var module = “sHistory”;
var header = {
“Authorization” : "Zoho-oauthtoken " + getAccessToken()
}

var options =

{
‘method’:“get”,

'headers': header,

'contentType':'application/x-www-form-urlencoded',

'page': page,

'per_page': perPage

};

var url = “https://recruit.zoho.com/recruit/v2/” + module;

var res = UrlFetchApp.fetch(url,options);

return JSON.parse(res);

}

function rowcount()

{

var token = getAccessToken();

var module = “sHistory”;

var rows = 0;

var go = true;

var i = 1;

var data;

while (go) {

data = getRecordsByPage(i,200,token,module);

if (Number(data.info.count) < 200) {

  go = false;

};

if ((i%10) == 0) {

   go = false; 

}

rows = Number(rows) + Number(data.info.count);

  i++;

  

  Utilities.sleep(15000);

}

  return rows;   

}

function propertiesstorage()

{

// saving rowcount in GAS properties

var scriptProperties = PropertiesService.getScriptProperties();

scriptProperties.setProperty(“sHistoryRows”,rowcount());

//reading rowcount from GAS properties

var scriptProperties = PropertiesService.getScriptProperties();

var datacount = scriptProperties.getProperties(“sHistoryRows”,rowcount());

for(var key in datacount)

{

Logger.log(key,datacount[key,"Stored "+ rowcount()]);

return key,datacount[key,rowcount()];

}

}

function comparedata()

{

var bqdata = getBigQueryTableRowCount();

var zdata = propertiesstorage();

if(bqdata != zdata)

{

Logger.log("rowcount does not matches between Big Query and Zoho Recruit SHistory"); 

}
}