New OAuth2 access token is not saved


I’m using the Exact Online API with OAuth2 (support).

The OAuth2 flow is working, until a token needs to be refreshed. As you can see in this image I do multiple requests to the Exact API, authorised with OAuth2:

When an access token is expired, it successfully refreshes the token in the first request. But in the second request, I get this error:

    "status": "rejected",
    "reason": {
        "body": {
            "error": "unauthorized_client",
            "error_description": "Old refresh token used."
        "code": "EAUTH"

It looks like it is trying to refresh the token for a second time, so it seems like the new access token received in the first refresh request is not saved properly yet before the second request starts.
After I restart the workflow it successfully runs the whole workflow.

This behaviour makes it impossible to run the workflow as a cron job.

Can you please help me resolve this?

Thanks a lot!

Are the requests happening on one node or on two different ones?

Hi @jan ,

The requests are happening in two different nodes. If you look at this screenshot, in the green circled one the refresh token is successfully requested, the red circled one throws the error:

Ah OK, then it sadly makes sense. That is a known issue. A fix got already implemented here:

It does however require a change in literally every node. This PR does that but there are sadly also a lot of other nodes of other people out there. So before we make this breaking change did we want to see if we can bundle some breaking changes together to not having to break things multiple times. For that reason do I have currently sadly no ETA on when it will be merged.

Do you run n8n via Docker? Because then you could easily build an own image with that fix included.

Build very fast a docker-image from that branch: n8nio/n8n:load-creds-db

You can see if that fixes your problem. This image is however currently untested and will not be updated.

This fixed the issues for now, I hope the PR is merged soon!

Glad to hear that it works. As it is a breaking change (on the code side) are we currently waiting on getting also another feature ready with another breaking change to not cause to many problems for users with custom nodes. Once that is ready will we release them together.

We are unfortunately running into the same issue, also with the Exact Online API.

Is there already a time window for the release of this fix?
It would be especially important for use in the authentication part of the ‘HTTP Request’ node.

Fix got released with 0.135.0

I am using version 0.151.0, and the issue occurs again with the exact same error message:

{"status":"rejected","reason":{"body":{"error":"unauthorized_client","error_description":"Old refresh token used."},"code":"EAUTH"}}