How to prevent callback of AuthenticationChallengeHandler listener getting triggered multiple times when access token expires?

Discussion created by buddhas on Apr 30, 2020

I am using ESRI online map in my project. To find a route and calculate the estimated time of arrival (ETA) of a place I am using ESRI RouteTask. I have implemented AuthenticationChallengeHandler in a service. The callback method handleChallenge of AuthenticationChallengeHandler gets triggered whenever an access token expires. Here we need to write logic to retrieve a new access token. But the problem is handleChallenge callback method sometimes gets triggered multiple times. This does not happen all the time. I could not find the exact scenario when it gets triggered multiple times. Is there any way to prevent multiple executions of the callback?