# Update secrets value using custom code

**URL:** <https://community.hubspot.com/t/update-secrets-value-using-custom-code/59898>\
**Category:** APIs & Integrations\
**Created:** [June 28, 2022, 12:50am UTC](https://community.hubspot.com/t/update-secrets-value-using-custom-code/59898 "2022-06-28T00:50:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rechavar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rechavar/32/194703_2.png) [@rechavar](https://community.hubspot.com/u/rechavar)\
**Post date:** [June 28, 2022, 12:50am UTC](https://community.hubspot.com/t/update-secrets-value-using-custom-code/59898/1 "2022-06-28T00:50:03Z")

</div>

Hi everybody!!! Happy Summer!!!  
So.. Once again its me looking for answers 😅  
The thing is, I have a custome code in a workflow, this custom code inputs secrets, the access token and the refresh token for ~~whatever~~ API. I need to update the access token using the refresh token when access token get declined, as always, one last and thing, Im using python.  
Hope that someone can helps me with this situation, been looking on forum and documentation but nothing that can fullfil my situation.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [June 28, 2022, 6:09pm UTC](https://community.hubspot.com/t/update-secrets-value-using-custom-code/59898/2 "2022-06-28T18:09:07Z")

</div>

Hey, @rechavar 👋 Thanks for the question. Let’s see if we can get the conversation started — @taran42 do you have any thought on if this is possible? Or what additional details @rechavar can provide to give more context here?

Thank you! — Jaycee

---

<div class="post-metadata">

**Author:** ![taran42](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/taran42/32/105524_2.png) [@taran42](https://community.hubspot.com/u/taran42)\
**Post date:** [June 29, 2022, 1:35pm UTC](https://community.hubspot.com/t/update-secrets-value-using-custom-code/59898/3 "2022-06-29T13:35:29Z")

</div>

@rechavar This isn’t a task that I am familiar with performing myself, so I can only make a recommendations.

I’d start by checking out the Hubspot documentation here: [Refresh OAuth 2.0 access token](https://legacydocs.hubspot.com/docs/methods/oauth2/refresh-access-token)

There’s also a good article detailing the process here: [How to get HubSpot API key and Access Token](https://www.jeevangupta.com/getting-started-with-hubspot-api-hubspot-api-key-and-access-token/)

---

<div class="post-metadata">

**Author:** ![rechavar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rechavar/32/194703_2.png) [@rechavar](https://community.hubspot.com/u/rechavar)\
**Post date:** [June 30, 2022, 9:49pm UTC](https://community.hubspot.com/t/update-secrets-value-using-custom-code/59898/4 "2022-06-30T21:49:09Z")

</div>

Mmmm not what i need, look, i have the access token an the refresh token of other API. The thing is, this values are input in my custom code as secret, but the custome code needs to change the access token using the refresh token when the AT fails in the authentication process. so… how can i change these secrets using python as my programming lenguage in the custome code??

---

<div class="post-metadata">

**Author:** ![WaydeChristie1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/waydechristie1/32/10224_2.png) [@WaydeChristie1](https://community.hubspot.com/u/WaydeChristie1)\
**Post date:** [January 10, 2023, 4:39am UTC](https://community.hubspot.com/t/update-secrets-value-using-custom-code/59898/5 "2023-01-10T04:39:49Z")

</div>

I have the same requirement here: [https://community.hubspot.com/t5/HubSpot-Ideas/Refreshing-custom-code-secrets/idi-p/561010](https://community.hubspot.com/t5/HubSpot-Ideas/Refreshing-custom-code-secrets/idi-p/561010)

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [January 10, 2023, 4:17pm UTC](https://community.hubspot.com/t/update-secrets-value-using-custom-code/59898/6 "2023-01-10T16:17:50Z")

</div>

Thanks for sharing! I added an upvote ✅

---

<div class="post-metadata">

**Author:** ![padamopoulou](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@padamopoulou](https://community.hubspot.com/u/padamopoulou)\
**Post date:** [August 29, 2023, 1:24pm UTC](https://community.hubspot.com/t/update-secrets-value-using-custom-code/59898/7 "2023-08-29T13:24:38Z")

</div>

Hello everyone, do we have any updates on this one? It’s a requirement I also need . TY!
