Confluence API OAuth 2.0 Automation

Hello,
I have recently been working on refactoring pipelines not to use the Atlassian API token to post reports to Confluence pages, but to use the recommended OAuth 2.0 authorization. To do so, I’ve created an app in the developer console, gave it necessary permissions, and authorized myself towards it.
However, I am experiencing issues with the authorization through GitHub Actions pipeline when automating the process of posting test reports to a certain Confluence page.
I create the App in the Atlassian Developer Console, follow the steps for authorization, authorize myself, obtain the code=, and get both the access_token and the refresh_token. After this I put the values of the refresh token in my script, and I can authorize myself for an hour, and in that hour I can run the pipeline as many times as I want (with the same credentials), after that period, the refresh token doesn’t work for me even though I found online that it should last for 90 days.

I’ve read somewhere that the issue could be with the authorize session. I’m obtaining the code= parameter with my account, and therefore the session could only last for an hour (I’m not 100% sure with this). The solution I found for Atlassian Automation, is that I should use a service account. With the service accounts credentials, I could authorize it towards the newly created app in the developer console, and its session will last longer than an hour. Is this correct?

What would you recommend me to do?
Thanks in advance!