Провести аунтификацию в соостветствии с типом сервиса

@param   RequestInterface $request

@return RequestInterface
179190
protected function authentication(RequestInterface $request)
	{
		$uri = $request->getUri();
		$key = http_build_query(['key' => $this->getAccessKey()], null, '&');

		if (strlen($uri->getQuery()) > 0)
		{
			$key = '&'.$key;
		}

		return $request->withUri($uri->withQuery($uri->getQuery().$key));
	}
67620
public function getTokenFromRequest( RequestInterface $request ) {
		if ( $request->get( $this->key ) ) {
			return $request->get( $this->key );
		}

		if ( $request->post( $this->key ) ) {
			return $request->post( $this->key );
		}

		if ( $request->headers( $this->header ) ) {
			return $request->headers( $this->header );
		}

		return '';
	}
1151055
protected function configureRequest(RequestInterface $Request)
    {
        if ($Request->getStatus() >= Curl::STATUS_SENT){
            $Request->reset();
        }
        if (isset($this->properties[self::PROPERTY_HTTP_METHOD]) &&
            $this->properties[self::PROPERTY_HTTP_METHOD] !== ''){
            $Request->setMethod($this->properties[self::PROPERTY_HTTP_METHOD]);
        }
        $url = $this->configureURL($this->getOptions());
        if ($this->verifyUrl($url)) {
            $url = rtrim($this->getBaseUrl(),"/")."/".$url;
            $Request->setURL($url);
        }
        $data = ($this->getData()?$this->getData():NULL);
        $data = $this->configureData($data);
        $Request->setBody($data);
        if ($this->authRequired()){
            if (isset($this->Auth)){
                $this->Auth->configureRequest($Request);
            }
        }
        return $Request;
    }
32417
protected function sendRequest(RequestInterface $request)
    {
        try {
            $response = $this->httpClient->send(
                $request,
                $this->getRequestOptions()
            );

            $this->multipartResources = [];

            return json_decode($response->getBody());
        } catch (RequestException $e) {
            $this->throwRequestException($e);
        }
    }
175100
protected function authentication(RequestInterface $request)
	{
		if ($this->tokenRequired)
		{
			return $request->withHeader('Authorization', sprintf('OAuth %s', $this->getAccessToken()));
		}

		return $request;
	}
1121914
protected function doRequest(RequestInterface $request)
    {
        // Create the stream context options array with the required method offset.
        $options = ['method' => $request->getMethod()];

        // Set HTTP Version
        $options['protocol_version'] = $request->getProtocolVersion();

        // If data exists let's encode it and make sure our Content-Type header is set.
        $data = (string) $request->getBody();

        if (isset($data)) {
            // If the data is a scalar value simply add it to the stream context options.
            if (is_scalar($data)) {
                $options['content'] = $data;
            } else // Otherwise we need to encode the value first.
            {
                $options['content'] = http_build_query($data);
            }

            if (!$request->getHeader('Content-Type')) {
                $request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
            }

            // Add the relevant headers.
            $request = $request->withHeader('Content-Length', (string) strlen($options['content']));
        }

        // Speed up stream get URL
        // @see http://stackoverflow.com/questions/3629504/php-file-get-contents-very-slow-when-using-full-url
        // @see http://stackoverflow.com/questions/13679976/how-to-speed-up-file-get-contents
        $request = $request->withHeader('Connection', 'Close');

        // Build the headers string for the request.
        if ($headers = $request->getHeaders()) {
            // Add the headers string into the stream context options array.
            $options['header'] = HeaderHelper::toHeaderLine($headers, true);
        }

        // If an explicit timeout is given user it.
        if ($this->getOption('timeout')) {
            $options['timeout'] = (int) $this->getOption('timeout');
        }

        // If an explicit user agent is given use it.
        if ($this->getOption('userAgent')) {
            $options['user_agent'] = $this->getOption('userAgent');
        }

        // Ignore HTTP errors so that we can capture them.
        $options['ignore_errors'] = 1;

        // Follow redirects.
        $options['follow_location'] = (int) $this->getOption('follow_location', 1);

        foreach ((array) $this->getOption('options') as $key => $value) {
            $options[$key] = $value;
        }

        // Create the stream context for the request.
        $context = stream_context_create(['http' => $options]);

        // Capture PHP errors
        $php_errormsg = '';
        $track_errors = ini_get('track_errors');
        ini_set('track_errors', '1');

        $connection = @fopen($request->getRequestTarget(), Stream::MODE_READ_ONLY_FROM_BEGIN, false, $context);

        if (!$connection) {
            if (!$php_errormsg) {
                // Error but nothing from php? Create our own
                $php_errormsg = sprintf('Could not connect to resource: %s', $request->getRequestTarget());
            }

            // Restore error tracking to give control to the exception handler
            ini_set('track_errors', $track_errors);

            throw new \RuntimeException($php_errormsg);
        }

        $stream = new Stream($connection);

        if ($dest = $this->getOption('target_file')) {
            $content = '';
            StreamHelper::copyTo($stream, $dest);
        } else {
            $content = $stream->getContents();
        }

        $metadata = $stream->getMetadata();

        $stream->close();

        if (isset($metadata['wrapper_data']['headers'])) {
            $headers = $metadata['wrapper_data']['headers'];
        } elseif (isset($metadata['wrapper_data'])) {
            $headers = $metadata['wrapper_data'];
        } else {
            $headers = [];
        }

        return $this->getResponse($headers, $content);
    }
1316993
public function handle(RequestInterface $request)
    {
        $route = $this->dispatch($request);

        $handler = new ResolverHandler($this->container, $route);

        if (count($route->middlewares()) > 0)
        {
            $middlewares = (array) $route->middlewares();

            $dispatcher = new Dispatcher($middlewares, $this->container);

            return $dispatcher->process($request, $handler);
        }

        return $handler->handle($request);
    }
19216
public function match(RequestInterface $request)
    {
        return (
            $this->matchSchema($request->schema()) &&
            $this->matchMethods($request->method()) &&
            $this->matchHost($request->host()) &&
            $this->matchPath($request->path())
        );
    }
1282571
public function handle(RequestInterface $request)
    {
        $index = 0;

        while ($this->canSetNextCore($index)) {
            $this->middlewares[$index]->setNextCore($this->middlewares[$index + 1]);
            ++$index;
        }

        return $this->middlewares[0]->handle($request);
    }
106025
public function applyToRequest(RequestInterface $request)
    {
        $body = $this->streamFactory->createStream((string) $this->queryHelper);

        return $request
            ->withBody($body)
            ->withHeader('Content-Type', 'application/x-www-form-urlencoded');
    }
816292
protected function authenticateRequest(RequestInterface $request)
    {
        $uri = $request->getUri();
        parse_str($uri->getQuery(), $query);

        $query['key'] = Configuration::get('key');
        $query['token'] = Configuration::get('token');

        $uri = $uri->withQuery(http_build_query($query));

        return $request->withUri($uri);
    }
1208049
public function handle(RequestInterface $request): ResponseInterface
    {
        if (!array_key_exists($this->index, $this->middlewares)) {
            return $this->response;
        }

        $current = $this->index;

        ++$this->index;

        $response = $this->container->call([$this->middlewares[$current], 'process'], [$request, $this]);

        return $response;
    }
727900
protected function dispatch(RequestInterface $request)
    {
        $route = $request->attribute(Application::ROUTE_ATTRIBUTE);

        if ($route instanceof RouteInterface)
        {
            return $route;
        }

        $dispatcher = $this->container->get(Application::DISPATCHER);

        $path = $request->uri()->path();

        return $dispatcher->dispatch($request->method(), $path);
    }
695484
public static function setRequest(RequestInterface $request)
    {
        $coroutineId = self::getCoroutineId();
        self::$context[$coroutineId][self::REQUEST_KEY] = $request;
    }
176759
public static function forge(RequestInterface $request)
    {
        $headerSize = $request->getInfo(CURLINFO_HEADER_SIZE);
        $response   = $request->getRawResponse();
        $content    = (strlen($response) === $headerSize) ? '' : substr($response, $headerSize);

        $rawHeaders = rtrim(substr($response, 0, $headerSize));
        $headers    = [];

        foreach (preg_split('/(\\r?\\n)/', $rawHeaders) as $header) {
            if ($header) {
                $headers[] = $header;
            } else {
                $headers = [];
            }
        }

        $headerBag = [];
        $info      = $request->getInfo();
        $status    = explode(' ', $headers[0]);
        $status    = explode('/', $status[0]);

        unset($headers[0]);

        foreach ($headers as $header) {
            $headerPair = explode(': ', $header);

            if (count($headerPair) > 1) {
                list($key, $value)     = $headerPair;
                $headerBag[trim($key)] = trim($value);
            }
        }

        $response = new static($content, $info['http_code'], $headerBag);
        $response->setProtocolVersion($status[1]);
        $response->setCharset(substr(strstr($response->headers->get('Content-Type'), '='), 1));

        return $response;
    }
364042
public function onRequest( RequestInterface $request ) {
        $localizedUri = Uri::withQueryValue( $request->getUri(), 'lang', $this->getEndpoint()->getLang() );
        return $request->withUri($localizedUri);
    }
924720
public function init(RequestInterface $request)
    {
        $translator = $this->translator();

        $notice = $request->getParam('notice');
        switch ($notice) {
            case 'resetpass':
                $message = $translator->translate('Check your email for instructions to reset your password.');
                $this->addFeedback([
                    'level'       => 'notice',
                    'message'     => $message,
                    'dismissible' => false
                ]);
                break;

            case 'newpass':
                $message = $translator->translate('Log in with your new password.');
                $this->addFeedback([
                    'level'       => 'notice',
                    'message'     => $message,
                    'dismissible' => false
                ]);
                break;
        }

        return true;
    }