Hi I have made a credential for Exactonline inside n8n but for some reason it keeps expiring after a while.
Im getting this error after a while
error
unauthorized_client
error_description
Old refresh token used.
What could cause this error im self hosting my n8n instance on digital ocean
Have you added your callback URL to your exactonline app?
Yes I added it the auth workflow works fine but after a while it just gives me this error.
If I didn’t add the callback to my app it would give a error when connecting the account
| Workflow |
Status |
Started |
Run time |
Exec. ID |
| StockUpdates | Success | Jun 26, 14:56:56 | 2.672s | 29 |
| StockUpdates | Success | Jun 26, 15:13:27 | 2.213s | 31 |
| StockUpdates | Success | Jun 26, 15:29:13 | 1.662s | 36 |
| StockUpdates | Success | Jun 26, 16:01:44 | 3.994s | 48 |
| StockUpdates | Success | Jun 26, 16:02:27 | 2.616s | 49 |
| StockUpdates | Success | Jun 26, 16:04:09 | 2.357s | 50 |
| StockUpdates | Success | Jun 26, 16:04:10 | 2.221s | 51 |
| StockUpdates | Success | Jun 26, 16:04:11 | 2.523s | 52 |
| StockUpdates | Success | Jun 26, 16:04:55 | 1.992s | 54 |
| StockUpdates | Success | Jun 26, 16:09:26 | 1.919s | 55 |
| StockUpdates | Success | Jun 26, 16:09:32 | 2.356s | 56 |
| StockUpdates | Success | Jun 26, 16:09:33 | 2.073s | 57 |
| StockUpdates | Success | Jun 26, 16:15:13 | 3.092s | 59 |
| StockUpdates | Success | Jun 26, 16:15:15 | 2.482s | 60 |
| StockUpdates | Success | Jun 26, 16:15:15 | 2.801s | 61 |
| StockUpdates | Success | Jun 26, 16:26:26 | 3.127s | 65 |
| StockUpdates | Success | Jun 26, 16:26:26 | 2.796s | 66 |
| StockUpdates | Success | Jun 26, 16:26:26 | 3.831s | 67 |
| StockUpdates | Success | Jun 26, 16:30:47 | 1.821s | 68 |
| StockUpdates | Error | Jun 26, 16:41:50 | 6.171s | 69 |
| StockUpdates | Error | Jun 26, 16:41:50 | 6.141s | 70 |
here are the logs as you can see the refresh flow works for a hour and after that it starts giving errors
error = unauthorized_client
error_description = Old refresh token used.
I’m running into the exact same issue. Did you find a fix @Gsmplus?
Hi Paul, We are still testing so things I will give you a update if I find a solution.
@Marciano_Antonacci I noticed you had a similar problem did you manage to find a fix? Or @Jon?
@pauljunior, Small update I tried on the cloud version and i’m having the same issue.
Thanks for the update. I’m trying some things as well. First I thought maybe it was a simultaneous sync on the same webhook which possibly invalidates the refresh token (in your logs the problem also happens on the same second). But today it still invalidated even though the hook was only called once.
Yes I had the same idea I’m trying now with que mode and then seeing what happens and I also added a wait node after every webhook call
I was looking at this mode as well. We will implement it in our docker setup if it fixes the problem on your end.
Im sending a simple request to Exact now every 5 minutes to see if that does anything. Maybe it can’t handle a long time between calls. Don’t expect that will fix anything. But we’ll see.
Hi guys,
There is a community node you can use for Exact Online. https://www.npmjs.com/package/n8n-nodes-exact-online
The source code is available so you can check the auth there if you want to replicate it in an http request node.
What I know is that Exact and their Oauth2 implementation is a bit annoying. I do not remember the exact details for how long a refresh token stays valid but it should be long enough for standard syncing.
Hi Bram,
Thanks I tried with the community node buy I still ran into the same problems.
That is very odd. I use the node myself and do not run into the same issue.
Looking at the error the refresh is happening in a wrong way. Exact Online is very fussy about stuff.
Are you running multiple workflows at the same time using the Exact Online API? This could cause a race condition where you try to refresh the token while another flow is also doing the same.
I suspect the issue is being caused by the StockPositions webhook. When a single order contains multiple products, the webhook seems to trigger for all of them simultaneously. I’m currently testing with queue mode enabled to see if that resolves the problem.
So far it is working fine but I just want to make sure before marking it as a solution.
Ah, yeah then it will be the webhooks coming in at the same time that messes it up when the refresh happens.
n8n queue mode will not help with solving that.
I would push everything to an actual queue like rabbitmq and then process them one by one from there. Can also use Redis or something else, but the RabbitMQ native nodes provide all needed functionality.
It does seem to help because it not caused by the webhook itself but by the call that is made to exact right after here. So far it seems that my problem is solved @pauljunior.
This is what my workflow looks like @BramKn (I added the wait node to add a delay in between the webhook requests)
Thanks. We are using RabbitMQ now to queue the data for Exact and the issue seems to be solved with that solution as well!