Home » n8n» How to connect HubSpot to n8n? OAuth setup for beginners

How to connect HubSpot to n8n?

You can connect HubSpot to n8n by creating a HubSpot app, exposing your n8n instance to the internet, and completing the OAuth flow in n8n. This guide gives clear Docker and n8n Cloud steps, working commands, and security advice so you can automate HubSpot tasks quickly.

What You Need

  • A HubSpot developer account to create an app.
  • An n8n instance running locally via Docker or hosted on n8n Cloud.
  • A public URL for n8n (use ngrok or a domain with HTTPS) for OAuth redirect.
  • Basic command line access and a browser to authorize OAuth.

How to connect HubSpot to n8n — Step-by-step

  • Step 1: Run n8n with Docker. Use this command to start n8n locally on port 5678.
    docker run -it --rm -p 5678:5678 -e N8N_HOST=localhost -e N8N_PORT=5678 n8nio/n8n:latest
  • Step 2: Expose n8n publicly. If you run locally, create a tunnel. Example using ngrok:
    npx ngrok http 5678

    Note the https URL that ngrok shows. You will use it as the OAuth redirect base.

  • Step 3: Create a HubSpot app. In developers.hubspot.com:
    • Create a new app and set allowed OAuth redirect URL to: <your-public-url>/rest/oauth2-credential/callback.
    • Choose minimal scopes you need, for example: crm.objects.contacts.read and crm.objects.contacts.write.
    • Save and copy the Client ID and Client Secret.
  • Step 4: Add HubSpot credential in n8n.
    • Open n8n in your browser: http://localhost:5678 or your Cloud URL.
    • Go to Credentials > New Credential > HubSpot OAuth2.
    • Enter the Client ID and Client Secret from HubSpot.
    • Set the Authorization URL and Token URL only if required; n8n usually fills defaults for HubSpot.
    • Click Connect. Authorize the app in the HubSpot consent screen.
  • Step 5: Test a HubSpot API call in n8n.
    • Create a new workflow in n8n and add the HubSpot node.
    • Select the new HubSpot credential and choose an operation such as “Get All Contacts”.
    • Execute the node and confirm you see contact data from HubSpot.

Commands and a quick API test

Use this curl example after you obtain an access token to test HubSpot API directly.

curl -H "Authorization: Bearer <ACCESS_TOKEN>" https://api.hubapi.com/crm/v3/objects/contacts

n8n will manage tokens for you after the OAuth flow. You do not need to manually refresh tokens inside n8n.

Update

If you rotate the HubSpot client secret, update the credential in n8n immediately. If n8n updates or you change host URLs, re-run the OAuth connect step so redirect URIs match.

When you change scopes in HubSpot, reconnect the credential to grant the new permissions in n8n.

Security

  • Use HTTPS for your n8n public URL. Do not expose n8n without protection.
  • Limit HubSpot app scopes to only what your automation needs.
  • Keep Client ID and Client Secret private. Store secrets in n8n credentials, not in workflows.
  • Protect your n8n instance with basic auth or IP allowlist if running on a server.
  • Rotate credentials periodically and revoke old tokens in HubSpot if a compromise is suspected.

Done

After completing these steps you can automate HubSpot tasks inside n8n. Add triggers, map fields, and build workflows that create or update HubSpot records. Start small, test each node, and expand automation as you gain confidence.


If you use n8n Cloud, substitute your Cloud URL for the public URL and skip ngrok. Use the same redirect path /rest/oauth2-credential/callback when registering the HubSpot app.

Neil
Written by Neil

Neil is a true n8n geek who lives and breathes workflow automation. He dives deep into nodes, triggers, webhooks, custom logic, and self-hosting setups, sharing everything he learns about n8n on AutomationCompare.com. As part of a broader team of automation specialists, Neil focuses purely on mastering n8n and helping others unlock its full potential.

Keep Reading

Scroll to Top