For a project I need to continuously monitor the inbox of an email-address for incoming data and handle the messages accordingly. For this I am using the Microsoft GraphAPI, I have created an App on entra and have gone through all the required setup to fetch an initial access-token and refresh-token which I have been using the last 90 days to fetch new access-tokens to query the inbox. This worked perfectly for these 90 days but yesterday the system failed when the GraphAPI returned that my refresh-token had expired “due to inactivity”.
After again consulting the docs it seems like my initial setup was doomed to fail since a single refresh-token can only be extended by usage to a max of 90 days. (I therefore can also only conclude that the message returned by the API stating it expired due to inactivity is incorrect since I am 100% sure that I have been using the refresh-token daily to get access-tokens) My question now is how I should go about handling this? I want to avoid the need to manually re-authenticate to obtain a new access-token every 90 days. Is there a way to fully automate this process without any manual user input or authentication?
I have tried to automate the process of fetching new refresh-tokens but as far as I understand I can only fetch a refresh-token once with a manually generated access-token. Is the only option for me perhaps to fetch a new refresh-token with my old refresh-token periodically and save this locally? Basically stacking refresh token on refresh token.