What would be the correct process for detecting when and then obtaining a new token from Portal when the existing one expires?
One way would be to catch the error message and obtain a new token.
The Portal object in the API has a 'token' property, and an 'expires' property. I guess another method would be to check periodically whether the "expires" property is older than the current datetime.
But how to actually go about obtaining a new token? I expected there might be a method called 'refreshToken' or similar but not that I can find.
Cheers,
-Paul
I think that there is only the "generateToken" call to the server.
You can also generate a token with a long expiry by specifying "expiration" : 1000 or something for a large number of seconds validity. Otherwise check the expires property against the system time as you suggest.
Hi Neil
Where is the 'generateToken' method within the qml API?
Thanks,
-Paul
ArcGIS Rest api :
But I also see that there is this under the OAuth 2.0 section...
Hey Paul Haakma,
I believe that you are looking for the expires property in the Portal class. What you can do is compare this to the current time and if the current time is less than the expires time, generate a new token. Having said that, I do not believe that you would need to run this as ArcGIS Online tokens generally last for about 2 weeks straight before they expire.
ArcGIS Runtime SDK for Qt QML API: Portal Class Reference
I hope this helps!
Default token expiry is 60mins
My mistake. I must be thinking of another service I use.