I don't think there is a programmatic approach to refresh Oauth token as it's tied to your user login, but you can create a service account integration (JWT) which you can re-create using your application.
As nice as the mentioned Medium post is, it does not help a bit when using the JWT token. As here I can only recommend using Postman, taking the example curl-command from the JWT generation page (of the integration) and importing it to Postman.
Then you find that under the body part you have additional key/value pairs to fill in for the request to work:
These next to your regular Header key/value pairs:
Maybe this might help some others a little bit as I was nearly throwing my Macbook out of the window in frustration regarding the non functional Adobe documentation.