API that doesn't return a 401 when the credentials have expired

Describe the problem/error/question

I’m working on a new node. The new credentials is working but when it has expired, the API returns a 403 so n8n doesn’t call preAuthentication to renew it.

n8n expects API calls made with expired credentials to return a 401. I don’t own the API so I can’t change the return code.

How can I make n8n renew the credentials when it has expired?

What is the error message (if any)?

Error code: 403
Full message: Request failed with status code 403

Information on your n8n setup

  • n8n version: 1.90.2
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: MacOS Sequoia