wrtc.onNeedRESTtoken() is called when REST authentication token is about to expire and system should fetch a new token.
You can use this event to fetch a new REST authentication token.
About 75% of REST authentication token's expiration time has passed. A new token should be fetched before old one expires.
wrtc.onNeedRESTtoken(token)
You can use any method to fetch a new REST authentication token; function wrtc.fetchRESTtoken() provided for you is using HTTP GET.
The below example code fetches new REST authentication token from web URL stored as value p= in old token:
wrtc.onNeedRESTtoken(token) {
var path = token.match(/\np=(.*)/);
if ((path) && (path.length == 2))
wrtc.fetchRESTtoken(path[1], function(newtoken){wrtc.setRESTtoken(newtoken); wrtc.changeCredentials()});
}