The technique we use, for an automated process that has no user waiting, is to simply make a call to get a token via the API every time we need one. For a given thread of execution, we do so just once. But beyond that, we “get token” every time. Easier and sufficient so that we don’t need to address storing the token nor worry about it expiring, managing/flushing cache, etc.
Perhaps a similar approach would work okay in your situation.
#webMethods