Any idea how to renew a token-key in a long-process workflow?

Hello, I’m running a scenario that works ideally and as I need. Today I have found an issue that I did not think about before, and I am not very sure what would be the best approach to fix it…

I run a process that usually takes 15-20 minutes to complete. Step 1 generates a key from an API valid for 1800 seconds (30 minutes). The process is a loop of items that need to be processed in sub-workflows. Everything ok.

My problem today was that I had a bigger than the usual process of items that needed +30 minutes. It probably needed 50 minutes to complete, which should not be a problem in resource terms.

But in the middle of the process, the key expired after 1800 seconds, and the operation failed at item 305/611.

I had to re-manually assign the process in the item it failed and completed ok. But I would like to prevent this in the future with some kind of after every 25 minutes of the process, get a new token and use that new token in step 2. But I can’t figure out what the approach would be or what the flow would look like…

I’m open to any suggestions, and I appreciate any help brought on this.


upp, someone has any ideas? Thanks!

Hi @yukyo, you dm’ed me already, for visibility Iet me also post my thoughts here:

It seems to me you could either

  1. renew the token as part of every loop
  2. check if the token has expired in your loop and if so renew it
  3. handle the token in a separate workflow running every 25 minutes and store the results in a file or database which your main workflow reads in every loop

1 would create a bit of overhead but unless there’s some sort of limit on the tokens you can create it probably is the easiest approach.

Hi, thanks for your response.

Yeah, I have already thought about option one but discarded it as it would generate a lot of requests for a short time, which is not likely a good solution for this.

About option 2)
1- I know how to check if the token has expired? Using cron to check how much time has passed since it was created?
2- How do I make “step 2” to use the new token as the expression would be defined to a different “workflow,” no? (I mean, the workflow that “gets a new key” would be a different workflow with an other name
3- Yes, this could be achieved, but again would be too many requests to the database via API. Maybe a file would be an option…


Hey tbh these were just my first thoughts since you sent me a dm. I don’t have a fully working workflow ready I am afraid, this would require a bit of thinking as to how to best approach this. I’ll be away from the forum tomorrow, but if you’re still struggling next week let me know and I’ll set some time aside.

Why not option 1 but every 10 runs or 50 runs and not every run of the loop?


And how would you trigger every 50 runs inside the loop? Any javascript for that?

Fixed it using a javascript function that checks the current loop run and it triggers the api to renew the key as @treyr suggested.



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.