We've encountered a few scenarios where the runtime (100.4) doesn't try to refresh an expired token for secured resources. The most recent one we've worked around is DownloadPreplannedOfflineMap from the DownloadPreplannedOfflineMapJob. It seems that the download doesn't try to refresh an expired token if the call returns a 498 status code.
Shortened stacktrace (removed our callstack):
System.Net.Http.HttpRequestException: Response status code does not indicate success: 498 ().
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Esri.ArcGISRuntime.Internal.RequestRequiredHandler.<IssueRequestAndRespond>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
We've seen this exception occur in other offline scenarios but have since added other calls through the runtime that have alleviated the issue.
I have seen that the runtime does react to a 401 status code and the 498 is put in the response content, whereas in this issue's case the status code returned is 498.
Is there any way to get the runtime to react appropriately to the 498 when it is returned as a status code so that it will try to refresh the token? I'd like to be able to write a fix that encompasses the whole project rather than having to test every call to see if it will or will not refresh tokens.
Can you share some code snippet on how you are handling authentication challenge or adding credentials? At what stage in your app do you get error code 498 (invalid token)? The default client handler we use checks for requests with invalid token and if a token credential is available for the request, it will refresh the token.
You can use ArcGISHttpClientHandler.HttpRequestBegin to find out which request is failing or if you have already set challenge handler Authentication.Current.ChallengeHandler = new ChallengeHandler ((info) =>{ // you can check here });
Thanks.