I need some help regarding codebase, There is a case where I need to update a credentials from a node.
My Case: I have access token in my database (credentials entity) and it can expire after few days but I can programmatically generate a new token (with the help of some other parameters) I want to save new token in credentials entity.
This is what I tried:
Just like getCredentials I tried adding a method updateCredentials in NodeExecuteFunctions.ts, but seems like we don’t have DB access in core package.
Can anyone please guide me, how to do this ? Any code pointers I can follow ? I just need to update credentials from my node
Can’t you renew the token within the same workflow? If it’s an HTTP Request, it would probably return 401 when the token is expired. If so, then you refresh it and then use the new refreshed token to continue the workflow.
Also, perhaps you can reference the token in the credentials using expressions? You can also access env variables from the credentials.
Sorry, there is currently no officially supported way to change credentials via a node and you are also correct that core does not know anything about a DB.
Is a long time that I wrote all of that code but the only simple way I can think of right now to make that possible is the very hacky and ugly way of doing it via the n8n API the frontend uses. So an HTTP request in the node.
I also tried to use the static global data to store it. It saves a lot of the tokens and for automatic executions it seems to be working well. But it is not shared between manual executions. For each of them a new token is requested.
I am in the exact same situation where I would like to update my credentials from a node… Did you find another solution since your post ?
Otherwise, what is the HTTP endpoint you take about in your workaround ?