Overview
The Marketing Events Sync script requires a valid HubSpot access token to authenticate API requests. The token is used to fetch marketing events and create custom object records in your HubSpot portal.Access Token Setup
The access token is defined at the beginning of the main function inevents.js:2:
Environment Variable Approach (Recommended)
The recommended approach is to store your access token in an environment variable and read it at runtime.PowerShell Setup
Set the environment variable in PowerShell:Node.js Implementation
Updateevents.js to read from the environment variable:
Token Usage
The access token is used in two types of API requests:1. Marketing Events API
Fetches marketing events with pagination (events.js:15-19):
2. CRM Objects API
Creates and searches deal records (events.js:298-304):
Required Permissions
Your HubSpot access token must have the following scopes:Marketing Events
Read access to marketing events API
CRM Objects
Read and write access to deals (custom objects)
Security Best Practices
Use Private Access Tokens
Generate a private app access token from HubSpot Settings > Integrations > Private Apps
Troubleshooting
401 Unauthorized Error
If you receive a 401 error, verify:- The token is valid and not expired
- The token has the required scopes
- The token is correctly formatted in the Authorization header
Token Format
HubSpot private access tokens typically start withpat-na1- or pat-eu1- depending on your data hosting location.