Get Data from API not saving when running API from webhook

This is doing my head in,

I am recieving a webhook that tells me a uuid and the type of object, when the webhook is detected it fires a workflow.

The workflow then sees if I’m authenticated (via a do if token expiry is < current date) with the 3rd party that I recieved the webhook from and if it to old sends the “refresh token” to “get data from api” which re authenticates and I save the new token in a type called “vendor” and a field called “api token”.

The api token contains the refresh token and the access token

I then use the access token to search the uuid in the 3rd party and bring back the actual object which I use to update stuff on my end.

Perfect all good.

I then fire another webhook and all of a sudden my refresh token is not valid, not only that but I it shouldnt even look to re authenticate as the expiry is not < current date

one theory I have is that on the first call is updating the token but once the workflow is finished it isn’t saving the new token to the vendor, so next time the vendors access token is the same on my end however the 3rd party is on a new one.

There is something seriously fishy going on, I feel like the workflows are not following any of my logic and doing what they please

I can do the exact same thing and refresh over and over again the token when I’m logged in however possibly the webhook which is un authenticated is causing the trouble.

Why it manages to work fine the first thing, create and modify other objects is beyond me

Alright so I have fixed it but I still dont understand the problem.

when executing the workflow I pass the refresh token as a text by referencing the vendor-token-refresh token. then in the workflow the authentication call passes that value to the 3rd part and voila.

Absolutely stupid. I fail to understand why there is a difference passing the value to the workflow than to referencing the exact same object from inside the workflow.