Get payload data.

@param \Psr\Http\Message\ServerRequestInterface|null $request Request to get authentication information from.
@return object|null Payload object on success, null on failure
166336
public function getPayload(ServerRequestInterface $request = null)
    {
        if (!$request) {
            return $this->payload;
        }

        $payload = null;
        $token = $this->getToken($request);

        if ($token !== null) {
            $payload = $this->decodeToken($token);
        }

        $this->payload = $payload;

        return $this->payload;
    }
1128335
public function get($request, $params = null, $authenticate = true) {
        if (is_string ($request)) {
            $request = array(
                "uri" => $request,
                "params" => $params,
                "authenticate" => $authenticate
            );
        }

        $request["params"] = isset ($request["params"]) && is_array ($request["params"]) ? $request["params"] : array();

        if (!isset ($request["authenticate"]) || $request["authenticate"] !== false) {
            $request["params"]["access_token"] = $this->get_access_token();
        }

        $result = MPRestClient::get($request);
        return $result;
    }
382269
public function getCredentials(Request $request)
    {
        $tokenExtractor = $this->getTokenExtractor();

        if (!$tokenExtractor instanceof TokenExtractorInterface) {
            throw new \RuntimeException(sprintf('Method "%s::getTokenExtractor()" must return an instance of "%s".', __CLASS__, TokenExtractorInterface::class));
        }

        if (false === ($jsonWebToken = $tokenExtractor->extract($request))) {
            return;
        }

        $preAuthToken = new PreAuthenticationJWTUserToken($jsonWebToken);

        try {
            if (!$payload = $this->jwtManager->decode($preAuthToken)) {
                throw new InvalidTokenException('Invalid JWT Token');
            }

            $preAuthToken->setPayload($payload);
        } catch (JWTDecodeFailureException $e) {
            if (JWTDecodeFailureException::EXPIRED_TOKEN === $e->getReason()) {
                throw new ExpiredTokenException();
            }

            throw new InvalidTokenException('Invalid JWT Token', 0, $e);
        }

        return $preAuthToken;
    }
588518
public function getRequest( Request $request ) {
		$response = $this->getClient()->request(
			'GET',
			$this->apiUrl,
			$this->getClientRequestOptions( $request, 'query' )
		);

		return $this->decodeResponse( $response );
	}
907329
protected static function currentRequest(HTTPRequest $request = null)
    {
        // Ensure we only use a registered HTTPRequest and don't
        // incidentally construct a singleton
        if (!$request && Injector::inst()->has(HTTPRequest::class)) {
            $request = Injector::inst()->get(HTTPRequest::class);
        }
        return $request;
    }
728617
function payload( )
    {
        $contentType = $this->ContentType;
        // accommodate re-serializing content after we got a forced content-type
        if ( $pos = strpos( $contentType, ';' ) !== false )
        {
            $contentType = substr( $contentType, 0, $pos );
        }
        if ( $contentType == '' )
        {
            $contentType = $this->defaultContentType;
        }

        if ( $this->IsFault )
        {
            // default representation of an error, hand picked
            $value = array( 'faultCode' => $this->FaultCode, 'faultString' => $this->FaultString );
            // send an HTTP error code, since there is no other way to make sure
            // that the client can tell apart error responses from valid array responses
            // try some meaningful mapping (it's REST, baby!)
            switch( $this->FaultCode )
            {
                case ggWebservicesServer::INVALIDMETHODERROR:
                    header( $_SERVER['SERVER_PROTOCOL'].' 404 Not Found' );
                    break;
                case ggWebservicesServer::INVALIDPARAMSERROR:
                case ggWebservicesServer::INVALIDCOMPRESSIONERROR:
                case ggWebservicesServer::INVALIDREQUESTERROR:
                    header( $_SERVER['SERVER_PROTOCOL'].' 400 Bad Request' );
                    break;
                case ggWebservicesServer::INVALIDAUTHERROR:
                    header( $_SERVER['SERVER_PROTOCOL'].' 403 Forbidden' );
                    break;
                default:
                    header( $_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error' );
            }
        }
        else
        {
            $value = $this->Value;
        }

        switch( $contentType )
        {
            case 'php':
            case 'application/x-httpd-php':
                return var_export( $value );
            case 'phps':
            case 'application/vnd.php.serialized':
                return serialize( $value );
            case 'application/json':
                $json = json_encode( $value, JSON_FORCE_OBJECT );
                if ( $this->JsonpCallback != false )
                {
                    $json = $this->JsonpCallback . '(' . $json . ')';
                }
                return $json;
            case 'text/plain':
                return is_string( $value ) ? $value : var_export( $value, true );
            case 'text/html':
                // in theory both html and body tags are not mandatory. But getting here is just a case of bad coding anyway
                return is_string( $value ) ? $value : '<html><body>' . htmlspecialchars( print_r( $value, true ) ) . '</body></html>';
            default:
                header('HTTP/1.1 406 Not Acceptable');
                // two 'non standard but existing' mimetype defs for php code and serialized
                return "REST responses cannot be serialized as '$contentType'. Currently supported: application/json, application/x-httpd-php, application/vnd.php.serialized";
        }

    }
302716
public static function getApiKey($request)
    {
        // Check for API key in request parameters.
        $apiKey = $request->query('api_key');
        if (empty($apiKey)) {
            // Check for API key in request HEADER.
            $apiKey = $request->header('X_DREAMFACTORY_API_KEY');
        }
        if (empty($apiKey)) {
            // Check for API key in request payload.
            // Skip if this is a call for system/app
            $route = $request->getPathInfo();
            if (strpos($route, 'system/app') === false) {
                $apiKey = $request->input('api_key');
            }
        }

        return $apiKey;
    }
1357436
protected function getRouteFromRequest(Request $request)
    {
        $attributes = $request->attributes->get('_route_params');

        if (isset($attributes[RouteObjectInterface::ROUTE_OBJECT])
            && ($attributes[RouteObjectInterface::ROUTE_OBJECT] instanceof RouteInterface)
        ) {
            return $attributes[RouteObjectInterface::ROUTE_OBJECT];
        }

        return null;
    }
702729
protected function dispatchRequestToAuthorizationServer(ServerRequest $request)
    {
        return json_decode($this->server->respondToAccessTokenRequest(
            $request, new Response
        )->getBody()->__toString(), true);
    }
214335
function payload()
    {
        if ( $this->IsFault )
        {
            return json_encode( array(
                'content' => null,
                'error_text' => $this->FaultString() ) );
        }
        else
        {
            return json_encode( array(
                'content' => $this->Value,
                'error_text' => null ) );
        }
    }
889881
private function getContentFromRequest(Request $request): array
    {
        $data = json_decode($request->getContent(), true);
        foreach ($data as $key => $value) {
            if ($value === null || $value === '') {
                unset($data[$key]);
            }
        }
        return $data;
    }
879193
private function matchRequest(ServerRequestInterface $request): ?callable
    {
        try {
            $parameters = $this->matcher->match(
                $this->cleanSymfonyHandler($request->getUri()->getPath())
            );
        } catch (ResourceNotFoundException $e) {
            /* Do nothing, keep the framework to manage it */
        }

        if (empty($parameters['_controller'])) {
            return null;
        }

        if (\is_callable($parameters['_controller'])) {
            if (\is_string($parameters['_controller']) && false !== \strpos($parameters['_controller'], '::')) {
                return \explode('::', $parameters['_controller']);
            }

            return $parameters['_controller'];
        }

        if (!$this->container->has($parameters['_controller'])) {
            return null;
        }

        /**
         * @var callable
         */
        $entry = $this->container->get($parameters['_controller']);

        if (\is_callable($entry)) {
            return $entry;
        }

        return null;
    }
644185
private function getLocalIp(ServerRequestInterface $request): ?string
    {
        $server = $request->getServerParams();
        if (!empty($server['REMOTE_ADDR']) && self::isValid($server['REMOTE_ADDR'])) {
            return $server['REMOTE_ADDR'];
        }

        return null;
    }
719196
public function getUser(ServerRequest $request)
    {
        $payload = $this->getPayload($request);

        if (empty($payload)) {
            return false;
        }

        if (!$this->_config['queryDatasource']) {
            return json_decode(json_encode($payload), true);
        }

        if (!isset($payload->sub)) {
            return false;
        }

        $user = $this->_findUser($payload->sub);
        if (!$user) {
            return false;
        }

        unset($user[$this->_config['fields']['password']]);

        return $user;
    }
1218084
function payload()
    {
        if ( $this->IsFault )
        {
            return json_encode( array(
                'result' => null,
                'error' => array( 'faultCode' => $this->FaultCode, 'faultString' => $this->FaultString ),
                'id' => $this->Id ) );
        }
        else
        {
            return json_encode( array(
                'result' => $this->Value,
                'error' => null,
                'id' => $this->Id ) );
        }
    }
137616
public function getDataFromRequestQuery(
        ServerRequestInterface $request,
        $object,
        DenormalizerContextInterface $context = null
    ) {
        return $this->deserializer->denormalize($object, $request->getQueryParams(), $context);
    }
575182
protected static function getParams(PsrRequest $request)
    {
        $params = (array)$request->getAttribute('params', []);
        $params += [
            'plugin' => null,
            'controller' => null,
            'action' => null,
            '_ext' => null,
            'pass' => []
        ];

        return $params;
    }