Hi all,
I'm creating a DataMiner protocol that communicates over HTTP. Every GET request to the API requires a bearer token for authentication, and this token must be refreshed every 10 minutes via a POST request to a token endpoint.
What is the recommended way to implement this in a protocol? Specifically:
-
How do I handle the bearer token refresh logic properly?
-
How can I ensure that the new token is automatically used when GET parameters are refetched (e.g., by a polling group)?
I’d appreciate guidance or examples on how others have handled this kind of setup.
Thanks in advance!
Hi Maya
One way to refresh your token is to check the status code and the response for every request in a QAction. You could trigger a new bearer token request if the status code is not 200 OK and the response indicates "token_expired" or something similar. SLProtocol.CheckTrigger(int triggerID) can be used inside the QAction to trigger the new bearer token request (QAction > Trigger > Action (execute) > Group > Session).
Hope this helps you out.
Kind regards
The login credentials are in raw json format