Old refresh token used Oauth2 Exactonline

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?

1 Like

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
StockUpdatesSuccessJun 26, 14:56:562.672s29
StockUpdatesSuccessJun 26, 15:13:272.213s31
StockUpdatesSuccessJun 26, 15:29:131.662s36
StockUpdatesSuccessJun 26, 16:01:443.994s48
StockUpdatesSuccessJun 26, 16:02:272.616s49
StockUpdatesSuccessJun 26, 16:04:092.357s50
StockUpdatesSuccessJun 26, 16:04:102.221s51
StockUpdatesSuccessJun 26, 16:04:112.523s52
StockUpdatesSuccessJun 26, 16:04:551.992s54
StockUpdatesSuccessJun 26, 16:09:261.919s55
StockUpdatesSuccessJun 26, 16:09:322.356s56
StockUpdatesSuccessJun 26, 16:09:332.073s57
StockUpdatesSuccessJun 26, 16:15:133.092s59
StockUpdatesSuccessJun 26, 16:15:152.482s60
StockUpdatesSuccessJun 26, 16:15:152.801s61
StockUpdatesSuccessJun 26, 16:26:263.127s65
StockUpdatesSuccessJun 26, 16:26:262.796s66
StockUpdatesSuccessJun 26, 16:26:263.831s67
StockUpdatesSuccessJun 26, 16:30:471.821s68
StockUpdatesErrorJun 26, 16:41:506.171s69
StockUpdatesErrorJun 26, 16:41:506.141s70

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.

1 Like

@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.

1 Like

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

1 Like

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.

1 Like

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.

1 Like

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.

1 Like

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.

1 Like

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.

1 Like

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)

1 Like

Thanks. We are using RabbitMQ now to queue the data for Exact and the issue seems to be solved with that solution as well!

1 Like