javascripttypescriptcallbackibm-mobilefirstworklight-server

Access Token returned although MFP Server is already Down


I shut down the MFP Server purposely and I still can receive/get the access token through the call WLAuthorizationManager.obtainAccessToken().

By comparing the Token I realize that is the same one as before (when the server was running)

First I don't why the WLAuthorizationManager.obtainAccessToken() goes to callback success function and not to the reject function, the second thing is that the token is the same.

this is my checkServer Function:

    function mfpServerAvailable() {

    var deferred = $q.defer();

        WLAuthorizationManager.obtainAccessToken().then(function (accessToken) {
            WL.Logger.debug("obtainAccessToken onSuccess: " + JSON.stringify(accessToken));
            deferred.resolve(true);
         }, function (response) {
            WL.Logger.debug("obtainAccessToken onFailure: " + JSON.stringify(response));
            deferred.reject(false);
         });

     return deferred.promise;
    }

Solution

  • If the token is already stored in your device and if its not expired, then the MF client SDK doesn't communicate with server to fetch new one.

    It returns the same access token as long as it is valid.