OAuth API - best practice

Hey there,

I was wondering if someone is using OAuth API within their apps. I would like to use this particular API for my app, however, there needs to be generated Bearer token first with validity for 1800 s and I am wondering how to handle this.

The first option that came to my mind was to call this endpoint at the Global canvas with a delay 1799 s and then repeat the call. Always will fill out the appVar with a valid Bearer token. I am just not sure that’s the best solution as there are a few things that worry me. It is reliable? If the user don’t close the app but only “hide it” and it will be running in the background, I guess this process will be still running and potentially using my API limit for this. Also, if this logic will be on the Global canvas, will it run while the app is opened or is there a better place for this logic?

This API will be used only on 2 screens, however, I am not sure if generating that key before the user proceeds to the respective page is a good idea, as it may slow down the loading of that page.

Any suggestions, ideas, please?