public function request( $method, $uri = '', array $options = [] )
    {
        //
        // Add authentication options
        //

        // Username and password
        if (
            !empty( $this->authentication_options['username'] )
            && !empty( $this->authentication_options['password'] )
        ) {
            $options['auth'] = [
                $this->authentication_options['username'],
                $this->authentication_options['password'],
            ];
        }
        // HTTP token
        else if ( !empty( $this->authentication_options['http_token'] ) ) {
            $options['headers']['Authorization']
                = 'Token token=' . $this->authentication_options['http_token'];
        }
        // OAuth2 token
        else if ( !empty( $this->authentication_options['oauth2_token'] ) ) {
            $options['headers']['Authorization']
                = 'Bearer ' . $this->authentication_options['oauth2_token'];
        }
        else {
            throw new \RuntimeException('No authentication options available');
        }

        try {
            $response = parent::request( $method, $uri, $options );
        }
        catch ( \GuzzleHttp\Exception\TransferException $e ) {
            $response = $e->getResponse();
        }

        return $response;
    }
public function request( $method, $uri = '', array $options = [] )
    {
        //
        // Add authentication options
        //

        // Username and password
        if (
            !empty( $this->authentication_options['username'] )
            && !empty( $this->authentication_options['password'] )
        ) {
            $options['auth'] = [
                $this->authentication_options['username'],
                $this->authentication_options['password'],
            ];
        }
        // HTTP token
        else if ( !empty( $this->authentication_options['http_token'] ) ) {
            $options['headers']['Authorization']
                = 'Token token=' . $this->authentication_options['http_token'];
        }
        // OAuth2 token
        else if ( !empty( $this->authentication_options['oauth2_token'] ) ) {
            $options['headers']['Authorization']
                = 'Bearer ' . $this->authentication_options['oauth2_token'];
        }
        else {
            throw new \RuntimeException('No authentication options available');
        }

        try {
            $response = parent::request( $method, $uri, $options );
        }
        catch ( \GuzzleHttp\Exception\TransferException $e ) {
            $response = $e->getResponse();
        }

        return $response;
    }
public function request ( $ method , $ uri = '' , array $ options = [ ] ) { // // Add authentication options // // Username and password if ( ! empty ( $ this -> authentication_options [ 'username' ] ) && ! empty ( $ this -> authentication_options [ 'password' ] ) ) { $ options [ 'auth' ] = [ $ this -> authentication_options [ 'username' ] , $ this -> authentication_options [ 'password' ] , ] ; } // HTTP token else if ( ! empty ( $ this -> authentication_options [ 'http_token' ] ) ) { $ options [ 'headers' ] [ 'Authorization' ] = 'Token token=' . $ this -> authentication_options [ 'http_token' ] ; } // OAuth2 token else if ( ! empty ( $ this -> authentication_options [ 'oauth2_token' ] ) ) { $ options [ 'headers' ] [ 'Authorization' ] = 'Bearer ' . $ this -> authentication_options [ 'oauth2_token' ] ; } else { throw new \ RuntimeException ( 'No authentication options available' ) ; } try { $ response = parent :: request ( $ method , $ uri , $ options ) ; } catch ( \ GuzzleHttp \ Exception \ TransferException $ e ) { $ response = $ e -> getResponse ( ) ; } return $ response ; }
Overrides base class request method to automatically add authentication options to request.
Overrides base class request method to automatically add authentication options to request .