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