Micah,
The practice we try to follow is if the token expires, we store the token, expiration time and refresh token (if any) in the Mendix database. Then we create a microflow that developers can call to get a token that is current.
An example for an MSGraph integration: there is microflow called GetTokenForLoggedInUser, which looks like this:
This microflow doesn’t require any parameters. It checks to see if there is a token stored in the Mendix database for the current user. If not, it initiates the process of generating a token via (Microsoft’s flavor of) OAuth. If there is a token, it checks to see if the token is expired. If it is expired the token is refreshed.
Here is the expiration decision:
and here is where the token gets refreshed, if needed
The benefits of this are:
Maybe this will give you some ideas about how to tackle the issue you are facing.
Did you take a look at the System.HttpResponse? Because you can just retrieve that and check the status code. And based on that do a refresh of the token.
Regards,
Ronald
I know that we can just do this but I was hoping that we could abstract the need to check and refresh the token from the developer’s microflows. If it were in an interceptor, we wouldn’t need to duplicate this loop.