N8n MS OAUTH2 Token Failing To Be Passed In 10% Of All Executions

Hi,

I’m getting the below error on around 10% of my workflow executions. These only happen on MS Graph or MS Teams requests.

My current n8n setup is:
Self hosted
V2.3.4
Postgres SQL
Docker Compose
Linux (ubuntu 24.04)

it seems as thou either the token isn’t being passed at all in the headers or the token has expired and a new one isn’t auto created. If I try to reprocess the failed execution then it almost always succeeds.

Any help would be greatly appriciated.

image

The error you’re seeing usually means the OAuth2 token isn’t being passed correctly or has expired. Since reprocessing the failed executions works, it suggests a temporary issue with token retrieval.

You might want to make sure the “Authenticate” setting in your MS Graph or MS Teams nodes is set up correctly, and that the “Scopes” are accurate. Also, consider checking your n8n logs for any related errors during the failed executions, which might provide clues about the token refresh process.

Welcome to the community @chrismid75

Update to the latest n8n version (currently 1.x), they’ve significantly improved OAuth token handling since v2.3.4.

Thanks @achamm I’ve changed the logs to debug now so will wait for the next failures and see what they say.

Your welcome!

Thanks @Miliaga - I mis-typed on my original post. I am on V2.3.6 already.

1 Like

If you have any more questions feel free to ask or you can mark one of our responses, or your own, as the solution to begin closing the post.

Have a good day!

Morning,

I’ve had a myriad of failures yesterday but unfortunately there is nothing in the logs

This is a real pain and seems to not be fixable… Is there a way to handle the error and keep retrying until it works?

@chrismid75 On your MS Graph

  • Click the node → Settings tab

  • Enable “Retry On Fail”

  • Set Max Tries: 3

  • Set Wait Between Tries: 2000ms (2 seconds)

This will auto retry when tokens fail, which should handle 90% of your issues.

Thanks @JohnHalex - I already have this set to retry 5 times at 5 second intervals. Normally I have to wait a couple of minutes before retrying to get the node to succeed.

If you need to wait minutes before it works, this isn’t a simple token refresh delay.

@chrismid75 Restart your n8n container to clear any cached credentials:

docker-compose restart n8n

Then reconnect your Microsoft credentials fresh.

Hi @JohnHalex

I’ve already restarted n8n, created new credentials and I get the same errors. It’s like n8n just isn’t passing any auth headers in the request “sometimes”