public function validateAccessToken($redirect = true)
    {
        $this->_do_not_redirect = !$redirect;
        $this->log('validateAccessToken()');

        //Check to see if token in session has expired
        if (!empty($this->_expires) && $this->_expires < time()) {
            $this->log('access token expired so reauthorize');

            if (strlen($this->_refresh_token) > 0) {
                //use a refresh token to get a new token
                return $this->requestAccessToken();
            }

            //Reauthorize
            $this->authorize($this->_scope);

            return false;
        }

        //Check for existing access token
        if (strlen($this->_access_token) > 0) {
            $this->log('has access token');

            return true;
        }

        //Reauthorize if no token was found
        if (strlen($this->_access_token) == 0) {
            $this->log('access token empty so authorize');

            //OAuth flows
            if ($this->isOauth1()) {
                //OAuth 1.0
                $this->log('authorizing with OAuth1.0a spec');

                //Request token and authorize app
                if (!isset($_GET['oauth_token']) && !isset($_GET['oauth_verifier'])) {
                    $this->log('initializing authorization');

                    //Request token
                    $this->requestToken();
                    //Authorize token
                    $this->authorize();

                    return false;
                }

                //Request access token
                if ($_GET['oauth_token'] != $_SESSION['oauth']['token']) {
                    unset($_SESSION['oauth']['token'], $_SESSION['oauth']['token_secret']);

                    return false;
                }

                $this->requestAccessToken();
                unset($_SESSION['oauth']['token'], $_SESSION['oauth']['token_secret']);

                return true;
            }

            //OAuth 2.0
            $this->log('authorizing with OAuth2 spec');

            //Authorize app
            if (!isset($_GET['state']) && !isset($_GET['code'])) {
                $this->authorize($this->_scope);

                return false;
            }

            if ($this->_debug) {
                $_SESSION['oauth']['debug']['received_state'] = $_GET['state'];
            }

            //Request an access token
            if ($_GET['state'] != $_SESSION['oauth']['state']) {
                unset($_SESSION['oauth']['state']);

                return false;
            }

            unset($_SESSION['oauth']['state']);
            $this->requestAccessToken('POST', array(), 'json');

            return true;
        }

        return false;
    }
public function validateAccessToken($redirect = true)
    {
        $this->_do_not_redirect = !$redirect;
        $this->log('validateAccessToken()');

        //Check to see if token in session has expired
        if (!empty($this->_expires) && $this->_expires < time()) {
            $this->log('access token expired so reauthorize');

            if (strlen($this->_refresh_token) > 0) {
                //use a refresh token to get a new token
                return $this->requestAccessToken();
            }

            //Reauthorize
            $this->authorize($this->_scope);

            return false;
        }

        //Check for existing access token
        if (strlen($this->_access_token) > 0) {
            $this->log('has access token');

            return true;
        }

        //Reauthorize if no token was found
        if (strlen($this->_access_token) == 0) {
            $this->log('access token empty so authorize');

            //OAuth flows
            if ($this->isOauth1()) {
                //OAuth 1.0
                $this->log('authorizing with OAuth1.0a spec');

                //Request token and authorize app
                if (!isset($_GET['oauth_token']) && !isset($_GET['oauth_verifier'])) {
                    $this->log('initializing authorization');

                    //Request token
                    $this->requestToken();
                    //Authorize token
                    $this->authorize();

                    return false;
                }

                //Request access token
                if ($_GET['oauth_token'] != $_SESSION['oauth']['token']) {
                    unset($_SESSION['oauth']['token'], $_SESSION['oauth']['token_secret']);

                    return false;
                }

                $this->requestAccessToken();
                unset($_SESSION['oauth']['token'], $_SESSION['oauth']['token_secret']);

                return true;
            }

            //OAuth 2.0
            $this->log('authorizing with OAuth2 spec');

            //Authorize app
            if (!isset($_GET['state']) && !isset($_GET['code'])) {
                $this->authorize($this->_scope);

                return false;
            }

            if ($this->_debug) {
                $_SESSION['oauth']['debug']['received_state'] = $_GET['state'];
            }

            //Request an access token
            if ($_GET['state'] != $_SESSION['oauth']['state']) {
                unset($_SESSION['oauth']['state']);

                return false;
            }

            unset($_SESSION['oauth']['state']);
            $this->requestAccessToken('POST', array(), 'json');

            return true;
        }

        return false;
    }
public function validateAccessToken ( $ redirect = true ) { $ this -> _do_not_redirect = ! $ redirect ; $ this -> log ( 'validateAccessToken()' ) ; //Check to see if token in session has expired if ( ! empty ( $ this -> _expires ) && $ this -> _expires < time ( ) ) { $ this -> log ( 'access token expired so reauthorize' ) ; if ( strlen ( $ this -> _refresh_token ) > 0 ) { //use a refresh token to get a new token return $ this -> requestAccessToken ( ) ; } //Reauthorize $ this -> authorize ( $ this -> _scope ) ; return false ; } //Check for existing access token if ( strlen ( $ this -> _access_token ) > 0 ) { $ this -> log ( 'has access token' ) ; return true ; } //Reauthorize if no token was found if ( strlen ( $ this -> _access_token ) == 0 ) { $ this -> log ( 'access token empty so authorize' ) ; //OAuth flows if ( $ this -> isOauth1 ( ) ) { //OAuth 1.0 $ this -> log ( 'authorizing with OAuth1.0a spec' ) ; //Request token and authorize app if ( ! isset ( $ _GET [ 'oauth_token' ] ) && ! isset ( $ _GET [ 'oauth_verifier' ] ) ) { $ this -> log ( 'initializing authorization' ) ; //Request token $ this -> requestToken ( ) ; //Authorize token $ this -> authorize ( ) ; return false ; } //Request access token if ( $ _GET [ 'oauth_token' ] != $ _SESSION [ 'oauth' ] [ 'token' ] ) { unset ( $ _SESSION [ 'oauth' ] [ 'token' ] , $ _SESSION [ 'oauth' ] [ 'token_secret' ] ) ; return false ; } $ this -> requestAccessToken ( ) ; unset ( $ _SESSION [ 'oauth' ] [ 'token' ] , $ _SESSION [ 'oauth' ] [ 'token_secret' ] ) ; return true ; } //OAuth 2.0 $ this -> log ( 'authorizing with OAuth2 spec' ) ; //Authorize app if ( ! isset ( $ _GET [ 'state' ] ) && ! isset ( $ _GET [ 'code' ] ) ) { $ this -> authorize ( $ this -> _scope ) ; return false ; } if ( $ this -> _debug ) { $ _SESSION [ 'oauth' ] [ 'debug' ] [ 'received_state' ] = $ _GET [ 'state' ] ; } //Request an access token if ( $ _GET [ 'state' ] != $ _SESSION [ 'oauth' ] [ 'state' ] ) { unset ( $ _SESSION [ 'oauth' ] [ 'state' ] ) ; return false ; } unset ( $ _SESSION [ 'oauth' ] [ 'state' ] ) ; $ this -> requestAccessToken ( 'POST' , array ( ) , 'json' ) ; return true ; } return false ; }
Validate existing access token

@param bool $redirect
@return bool
@throws IncorrectParametersReturnedException
Validate existing access token