I have an app that writes to a secured feature service and once the user signs in I want them to have have the option of staying signed in.
There is no obvious property or method on the UserCredentials object that seems to enable this so figured I'd use a timer. The user's first sign-in works. reliably. When I receive the token after the user signs in, I set the timer interval to half the time until tokenExpiry and set the timer's onTriggered signal to try to log in again by calling ServiceInfoTask.fetchFeatureServiceInfo().
But this doesn't get a new token or change the tokenExpiry. What is a correct method of doing this? Do I need to sign out first? Reinitialize the UserCredentials and/or reassign them to the ServiceInfoTask? Something else?
I'd suggest using the IdentityManager - ArcGIS Runtime SDK for Qt QML API: IdentityManager Class Reference
It is a singleton that handles all of the authentication challenges issued. It is a singleton that you can hook up to by using the Qml Connections component Signal and Handler Event System | Qt QML 5.7
When the userCredentialsRequired signal emits, then set your user credential object in that signal handler with the setCredential method.
The IdentityManager contains a credential cache that will auto refresh and request new tokens behind the scenes using the cached credentials.
Based on your suggestion I have been researching to try to understand how to utilize IdentityManager. I found a recent (Aug 3, 2016) GeoNet post by you indicating there is a QML sample, but I was only able to find a C++ sample illustrating IdentityManager. I tried to look through the C++ sample but I’ve never learned that language so I didn’t glean much. By any chance do you have any sort of example for QML?