Buildship newbie - dynamically change a secret key
I am trying to connect buildship to an external api that requires the access token to get refreshed every sixty minutes. I'd like to store the access token and an expiration date, and if the time is past the expiration date, refresh the token and update the expiration date. My plan is to use the secret manager to store the access token and expiration date, but I can't see a way to dynamically update the secret key every time I refresh the token. Is this possible? Should I use something else besides the secret manager?
3 Replies
AI Support Bot Information
<@1323091339658657840> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human!
Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers.
Please note: Team members will review and answer the questions on best efforts basis.
AI Response
It seems that dynamically updating the Secret Manager in BuildShip may not be the best approach for your use case, as it's primarily meant for storing static secrets securely. However, you can manage access tokens and refresh logic within your workflow using other methods. Here's a possible approach:
1. Create a Firestore Collection: Store the access token and expiration date in a Firestore collection within your BuildShip project. This will allow you to read and update these values as needed.
2. Schedule a Workflow: Set up a scheduled workflow that runs every hour to check the expiration date of your access token.
3. Check Expiration: In the workflow, read the current access token and expiration date from the Firestore collection. If the token is expired, proceed to the next step.
4. Refresh Token: Use an HTTP request node to call the external API's token refresh endpoint, which will provide you with a new access token and expiration date.
5. Update Firestore: Update the Firestore collection with the new access token and expiration date.
This method allows you to store and update the access token and expiration dynamically, ensuring the token is refreshed when needed without manually updating the Secret Manager.
For more details on using Firestore with BuildShip, you can refer to the documentation about using BuildShip's built-in Firestore database and nodes here.
If you need further assistance or have any questions about this process, feel free to reach out.
BuildShip AI Support
Hi @Matt Use the headers of the REST API to send your token, so that each time a new request is made, the live token is sent. example - https://docs.buildship.com/tutorials/secure-api#option-1-listening-for-authorization-header-from-a-request
Secure Your API Endpoint – BuildShip
A unified resource to start building your backend with low-code. Dive into triggers, nodes, and step-by-step guidance to jumpstart your workflow creation.