Reset access token per execution

Describe the issue/error/question

I am building a custom node which uses JWT for authorization. When generating the token, the database claim must be provided. This database is currently being set in the credentials options. I have a workflow where the database can change for each executions. However, n8n saves the access token across executions. I am using the preAuthentication method to generate the token.
Is it possible to reset the access token for each execution in case the database has changed? As a workaround I added a node operation to generate the token and then setting the access token manually in the credentials via an expression.

Information on your n8n setup

  • n8n version: 0.211.2

Hi @feelgood-interface, I don’t think n8n has a generic credential type supporting a JWT preAuthentication method I am afraid.

So it seems to me of handling this in your node-specific code would be the best approach here, but perhaps our resident node builder @marcus has another idea here?

Hi @feelgood-interface,
if you want to update the access token on each execution maybe the authenticate function could be helpful. I have recently given an example here:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.