wrong token changed and corrected

This commit is contained in:
Denise_Datinguinoo committed 2026-08-20 16:50:09 +02:00
1 parent 5dec745ab2
commit bb01ec92ce
2 files changed
+10 -12

No files matched your search

+4 -4
View File
@@ -6,9 +6,8 @@ async function createHubspotContacts(leadContact) {
properties: { properties: {
firstname: leadContact.firstname, firstname: leadContact.firstname,
lastname: leadContact.lastname, lastname: leadContact.lastname,
email: leadContact.contact.email, email: leadContact.contact?.email || '',
phone: leadContact.contact.phone, phone: leadContact.contact?.phone || ''
lead_source: 'Keystone'
} }
} }
@@ -29,7 +28,8 @@ async function createHubspotContacts(leadContact) {
return creationContact; return creationContact;
} }
catch (error) { catch (error) {
console.log('Error in creating the contacts.'); console.error('Dettaglio Errore 400 HubSpot:', JSON.stringify(error.response?.data, null, 2) || error.message);
return null;
} }
} }
+6 -8
View File
@@ -19,11 +19,9 @@ async function initializeHubspotConnection() {
hubspot.setClientSecret(auth.hClientSecret); hubspot.setClientSecret(auth.hClientSecret);
hubspot.setRedirectUri(auth.hCallback); hubspot.setRedirectUri(auth.hCallback);
if (!await hubspot.getAccessToken()) { const currentToken = await hubspot.getAccessToken();
console.log('No token found.') if (!currentToken) {
} throw new Error('Refresh token not found in cfg/hubspot.json. Complete the authentication OAuth first via browser.');
else {
console.log('Token loaded successfully');
} }
await hubspot.checkToken(); await hubspot.checkToken();
@@ -67,9 +65,9 @@ async function runConnector() {
console.log('Creation successful!'); console.log('Creation successful!');
// here we save the last time we ran the connector // here we save the last time we ran the connector
const currentDateTime = new Date().toISOString().split('T')[0]; //const currentDateTime = new Date().toISOString().split('T')[0];
fs.writeFileSync(FILE_PATH, JSON.stringify({ lastRun: currentDateTime }, null, 2)); //fs.writeFileSync(FILE_PATH, JSON.stringify({ lastRun: currentDateTime }, null, 2));
console.log('DateTime saved successfully in file last-modified-date.json'); //console.log('DateTime saved successfully in file last-modified-date.json');
console.log('All contacts have been created!'); console.log('All contacts have been created!');
} }