So I have had this code snippet working for sometime now. I create a contact on zoho books with it but today it started giving back 302 responses and redirecting me to a different url. I decided to check toke validity this is what I did but i get 302
const orgUri = `${process.env.ZOHO_BASE_URI}/organizations`;
// Define query options
const queryOptions = {
headers: {
Authorization: `Zoho-oauthtoken ${token}`,
'Content-Type': 'application/json',
},
method: 'GET',
};
try {
const response = await fetch(orgUri, queryOptions);
if (response.status === 200) {
console.log('Token is valid.');
const data = await response.json();
return true;
} else if (response.status === 401) {
console.log('Token is invalid or expired.');
return false;
} else {
console.log('Unexpected response:', response.status);
return false;
}
} catch (error) {
console.error('Error validating token:', error);
return false;
}
}