How to Obtain a Token From a HubSpot CLI-Created App?

matheus_lopesm
Member

Hello! I’m learning the HubSpot CLI, which is the local environment where I can upload projects and create apps, and I’d like to understand two things that weren’t clear to me when searching online, even after asking ChatGPT in several different ways:

1. Workflows allow us to use Custom Code Actions directly in the UI. In that setup, I need to generate a private app (now called a Legacy app) and create a secret using the token from that private app. However, I saw that it’s also possible to create a Custom Workflow Action through the HubSpot CLI. Do both options do the same thing? From what I’ve researched, it seems that a Custom Workflow Action only collects workflow data to be executed by an external endpoint. So, is it possible to create an action that runs inside the workflow as a Custom Workflow Action instead of using the UI-based Custom Code Action?

2. I created a private app directly through the CLI. However, when I go to Developers > Projects > my project > my private app, I’m unable to see the token under “Auth.” I’d like to use the token from this CLI-created private app as the secret in my workflow that already uses a Custom Code Action, but I can’t find it anywhere. Do I need to create it in some other way?

 
 
 
0 Upvotes
2 Replies 2
RubenBurdin
Top Contributor

Hi @matheus_lopesm , totally fair questions. HubSpot uses similar words for things that behave very differently, so it’s easy to conflate them.

A Custom Code Action runs code inside HubSpot’s workflow runtime. You paste Node.js in the UI, and HubSpot executes it for you. A Custom Workflow Action (the one you define in a Developer Project / via CLI) is not an “in-portal” code runner.

 

It’s a definition that makes HubSpot call your external actionUrl when the workflow step runs. So they don’t do the same thing, and you can’t replace a Custom Code Action with a Custom Workflow Action unless you’re comfortable hosting the logic yourself behind an HTTPS endpoint. HubSpot’s docs make this separation pretty explicit and for Custom Code Actions

(https://developers.hubspot.com/docs/apps/developer-platform/add-features/custom-workflow-actions )

(https://developers.hubspot.com/docs/api-reference/automation-actions-v4-v4/custom-code-actions )

 

On the token piece: “private apps” created through Projects are not the same UX as the old Private App screen, and HubSpot generally will not show you a reusable access token for an OAuth style app because the model is different. If your project app is configured for OAuth, you don’t get a static token to copy. You obtain access tokens by installing the app into a portal and completing the OAuth flow, then storing the resulting token securely on your side.

 

If you truly need a static token for server-to-server calls from a workflow custom code action, that’s still the classic Private App token created in the portal UI (Settings > Integrations > Private Apps). That token won’t appear inside the Developer Project “Auth” panel because it’s not part of the project app’s auth model.

So the mental model is: Custom Code Action + Private App token is simplest for quick server-to-server calls. Custom Workflow Action + OAuth is the “real app” approach, but you’ll host the endpoint and handle token storage/refresh outside HubSpot. If you share whether your CLI-created app is OAuth or “static” auth in its hsmeta, I can point to the exact expected token path.

Did my answer help? Please mark it as a solution to help others find it too.

Ruben Burdin Ruben Burdin
HubSpot Advisor
Founder @ Stacksync
Real-Time Data Sync between any CRM and Database
Stacksync Banner
0 Upvotes
BérangèreL
Community Manager
Community Manager

Hi @matheus_lopesm and welcome, we are so glad to have you here! 🧡

Thanks for reaching out to the HubSpot Community!

Here are some resources that might help you:

- Define a custom workflow action
- Workflows | Custom Code Actions
- Creating private apps with projects

I'd love to put you in touch with our Top Experts: Hi @sylvain_tirreau, @Anton and @Christensen do you have suggestions to help @matheus_lopesm, please?

Thanks so much and have a brilliant day!
Bérangère





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




0 Upvotes