Change node credentials at runtime

In my node I use an API with OAuth authentication.
I save the refresh token in the node credentials.
When the access token is refreshed, the API also returns a new refresh token.

How can I save the new refresh token in the credentials file at runtime?

I already tried it with RED.nodes.addCredentials (node.id, credentials);, but this does not change the credentials file.
After a restart, the old refresh token is active again.

Hi @alexkn

There is a long standing issue on the backlog to help handle this scenario.

Currently the only way to save anything to the credentials store is via a deploy - not something nodes are allowed to trigger of their own accord.

Until someone figures out how best to handle this scenario your options are limited.