How can I access secrets in a python custom code element? The example given is in js…
Hey, @anewhubspotuser
Thanks for reaching out. Can you link us to the specific page and example you are referring to, please?
I found some resources to help get us started:
- Refresh OAuth 2.0 access token
- How to get HubSpot API key and Access Token
- This post from a community member (thanks @taran42
) covering a similar request — Update secrets value using custom code
Thank you for the additional information! — Jaycee
I am referring to Workflows | Custom Code Actions - HubSpot docs . There is only a js example for handling secrets.
HubSpot has it in their documentation under the Get Started section in the Python code example, but when I used their code it didn’t work. I tried the below code and you can access a secret using it.
Replace SECRET_KEY in the code with your own.
import os
from hubspot import HubSpot
def main(event):
api = os.environ.get('SECRET_KEY')
I need Help to fix the token which was edited by mistake. Because of this all my automated whatsapp messages are stopped working
I do not have any coding knowledge. I took support from breeze assistant to create a associated property’s value in course. It created the workflow and required property and suggested me add legacy apps and service keys and i did step by step but it didnt work then it told me to edit the token. After that my all automated whatsapp messages stopped working. when crosschecked the token was using for all these messages. Breeze sent just sorry message and support team is telling they cant help as it is custom coding. I am fully in tension now. Can anyone help me to solve this issue ?
Hi @Neem and welcome, it’s a pleasure to have you on the HubSpot Community!
I can see why this feels urgent with all your automated WhatsApp messages stopped. Let’s narrow down exactly where the token was changed.
Please don’t share the token, service keys, or screenshots containing credentials publicly, and avoid making further changes for now. Could you confirm:
- Where the token was edited: a private app, workflow secret/custom-code action, or WhatsApp integration
- Which WhatsApp provider/app you use
- The exact error message, with sensitive details hidden
Here’s what’s likely happening: when you “edited the token,” you may have rotated the legacy app’s access token. Rotating creates a new token and starts expiring the old one. If your WhatsApp automation (workflow/integration) was still configured with the old token, it would now fail authentication, that matches what you’re seeing.
How to fix it:
- In your HubSpot account, go to Development → Legacy apps.
- Click the name of the private app used for both the property automation and your WhatsApp integration.
- On the Auth tab, check the current, active access token.
- If you see a pending rotation, you can click Cancel rotation, this cancels the expiration of the original token and revokes the newer one, restoring the original.
- Otherwise, copy the current active token and update it wherever your WhatsApp automation/integration references it (this part depends on where your WhatsApp tool stores the token, since it’s a third-party integration, you’d update it there).
Here are some resources that can help:
Now, I’d love to hear from our Top Experts: Hi @Anton and @SteveHTM do you have any insights to share with @Neem, please?
Thanks so much and have a wonderful day!
Bérangère
This post was created with the assistance of AI tools