stackmob-js-0.9.2.js
function(options) {
      options = options || {};

      //If we aren't running in OAuth 2.0 mode, then kick out early.
      if(!this.isOAuth2Mode()){
        if (options && options['error'])
          options['error']();
        return false;
      }

      //Check to see if we have all the necessary OAuth 2.0 credentials locally AND if the credentials have expired.
      var creds = this.getOAuthCredentials();
      var expires =  (creds && creds['oauth2.expires']) || 0;

      //If no accesstoken, mackey, or expires..
      if ( !_.all([creds['oauth2.accessToken'], creds['oauth2.macKey'], expires], _.identity) ){
        if (options && options['success']) options['success'](undefined);
        return false;
      }

      if ( !StackMob.hasExpiredOAuth() ) {
        //If not expired
        if (options && options['success'] ){
          options['success']( this.Storage.retrieve('oauth2.user') );
        }
        return this.Storage.retrieve('oauth2.user');
      } else if ( options && options['success']) {
        //If expired and async
        var originalSuccess = options['success'];
        options['success'] = function(input){
          var creds = StackMob.getOAuthCredentials();

          var loginField =  (creds['oauth2.userSchemaInfo'] && creds['oauth2.userSchemaInfo']['loginField']) ?
            creds['oauth2.userSchemaInfo']['loginField'] : this['loginField'];
          originalSuccess( input[loginField]);
        };
        this.initiateRefreshSessionCall(options);
      } else {
        //If expired and sync
        return false;
      }

    }
function(options) {
      options = options || {};

      //If we aren't running in OAuth 2.0 mode, then kick out early.
      if(!this.isOAuth2Mode()){
        if (options && options['error'])
          options['error']();
        return false;
      }

      //Check to see if we have all the necessary OAuth 2.0 credentials locally AND if the credentials have expired.
      var creds = this.getOAuthCredentials();
      var expires =  (creds && creds['oauth2.expires']) || 0;

      //If no accesstoken, mackey, or expires..
      if ( !_.all([creds['oauth2.accessToken'], creds['oauth2.macKey'], expires], _.identity) ){
        if (options && options['success']) options['success'](undefined);
        return false;
      }

      if ( !StackMob.hasExpiredOAuth() ) {
        //If not expired
        if (options && options['success'] ){
          options['success']( this.Storage.retrieve('oauth2.user') );
        }
        return this.Storage.retrieve('oauth2.user');
      } else if ( options && options['success']) {
        //If expired and async
        var originalSuccess = options['success'];
        options['success'] = function(input){
          var creds = StackMob.getOAuthCredentials();

          var loginField =  (creds['oauth2.userSchemaInfo'] && creds['oauth2.userSchemaInfo']['loginField']) ?
            creds['oauth2.userSchemaInfo']['loginField'] : this['loginField'];
          originalSuccess( input[loginField]);
        };
        this.initiateRefreshSessionCall(options);
      } else {
        //If expired and sync
        return false;
      }

    }
function ( options ) { options = options || { } ; //If we aren't running in OAuth 2.0 mode, then kick out early. if ( ! this . isOAuth2Mode ( ) ) { if ( options && options [ 'error' ] ) options [ 'error' ] ( ) ; return false ; } //Check to see if we have all the necessary OAuth 2.0 credentials locally AND if the credentials have expired. var creds = this . getOAuthCredentials ( ) ; var expires = ( creds && creds [ 'oauth2.expires' ] ) || 0 ; //If no accesstoken, mackey, or expires.. if ( ! _ . all ( [ creds [ 'oauth2.accessToken' ] , creds [ 'oauth2.macKey' ] , expires ] , _ . identity ) ) { if ( options && options [ 'success' ] ) options [ 'success' ] ( undefined ) ; return false ; } if ( ! StackMob . hasExpiredOAuth ( ) ) { //If not expired if ( options && options [ 'success' ] ) { options [ 'success' ] ( this . Storage . retrieve ( 'oauth2.user' ) ) ; } return this . Storage . retrieve ( 'oauth2.user' ) ; } else if ( options && options [ 'success' ] ) { //If expired and async var originalSuccess = options [ 'success' ] ; options [ 'success' ] = function ( input ) { var creds = StackMob . getOAuthCredentials ( ) ; var loginField = ( creds [ 'oauth2.userSchemaInfo' ] && creds [ 'oauth2.userSchemaInfo' ] [ 'loginField' ] ) ? creds [ 'oauth2.userSchemaInfo' ] [ 'loginField' ] : this [ 'loginField' ] ; originalSuccess ( input [ loginField ] ) ; } ; this . initiateRefreshSessionCall ( options ) ; } else { //If expired and sync return false ; } }
StackMob validates OAuth 2.0 credentials upon each request and will send back a error message if the credentials have expired.  To save the trip, developers can check to see if their user has valid OAuth 2.0 credentials that indicate the user is logged in.
StackMob validates OAuth 2 . 0 credentials upon each request and will send back a error message if the credentials have expired . To save the trip developers can check to see if their user has valid OAuth 2 . 0 credentials that indicate the user is logged in .