Get the JWT from the request.

@param \Illuminate\Http\Request $request

@throws \Exception

@return string
356443
protected function getToken(Request $request)
    {
        try {
            $this->validateAuthorizationHeader($request);

            $token = $this->parseAuthorizationHeader($request);
        } catch (Exception $exception) {
            if (! $token = $request->query('token', false)) {
                throw $exception;
            }
        }

        return $token;
    }
954833
protected function decodeJwtTokenCookie($request)
    {
        return (array) JWT::decode(
            $this->encrypter->decrypt($request->cookie(Passport::cookie())),
            $this->encrypter->getKey(), ['HS256']
        );
    }
675559
public function getOAuthCallbackAction(Request $request)
    {
        $this->initSessionBag();

        if ($request->query->get("state") != $this->sessionBag->get("hash")) {
            throw new UserException("Invalid session verification hash");
        }

        $guzzle = new GuzzleClient();
        try {
            $response = $guzzle->post($this->getTokenUrl(), array("body" => array(
                "client_id" => $this->getClientId(),
                "client_secret" => $this->getClientSecret(),
                "grant_type" => $this->grantType,
                "redirect_uri" => $this->getCallbackUrl($request),
                "code" => $request->query->get("code")
            )));
        } catch (ClientException $e) {
            $errCode = $e->getResponse()->getStatusCode();
            if ($errCode == 400) {
                $desc = jsonDecode($e->getResponse()->getBody(true), true);
                $code = empty($desc["code"]) ? 0 : $desc["code"];
                $message = empty($desc["error_message"]) ? "Unknown error from API." : $desc["error_message"];

                throw new UserException(
                    "OAuth authentication failed[{$code}]: {$message}",
                    null,
                    [
                        'response' => $e->getResponse()->getBody()
                    ]
                );
            } else {
                throw $e;
            }
        }

        $responseData = jsonDecode($response->getBody(true));

        $this->storeOAuthData($responseData);
        return $this->returnResult($responseData);
    }
843751
private function get_signature_method(&$request) {
    $signature_method =
        @$request->get_parameter("oauth_signature_method");
    if (!$signature_method) {
      $signature_method = "PLAINTEXT";
    }
    if (!in_array($signature_method,
                  array_keys($this->signature_methods))) {
      throw new OAuthException(
        "Signature method '$signature_method' not supported " .
        "try one of the following: " .
        implode(", ", array_keys($this->signature_methods))
      );
    }
    return $this->signature_methods[$signature_method];
  }
107330
protected function getTokenViaCookie($request)
    {
        // If we need to retrieve the token from the cookie, it'll be encrypted so we must
        // first decrypt the cookie and then attempt to find the token value within the
        // database. If we can't decrypt the value we'll bail out with a null return.
        try {
            $token = $this->decodeJwtTokenCookie($request);
        } catch (Exception $e) {
            return;
        }

        // We will compare the CSRF token in the decoded API token against the CSRF header
        // sent with the request. If they don't match then this request isn't sent from
        // a valid source and we won't authenticate the request for further handling.
        if (! Passport::$ignoreCsrfToken && (! $this->validCsrf($token, $request) ||
            time() >= $token['expiry'])) {
            return;
        }

        return $token;
    }
242752
public static function token(Request $request)
    {
        $authorization = $request->getHeader('Authorization');

        if (!isset($authorization[0])) {
            throw new HeaderWithoutAuthorizationException('The request does not contain the Authorization header');
        }

        $token = preg_replace('/^\w+\s/', '', $authorization[0]);

        return Authenticator::decodeToken($token);
    }
1279964
private function getSignatureMethod(&$request)
    {
        $signatureMethod = @$request->getParameter("oauth_signature_method");
        if (!$signatureMethod) {
            $signatureMethod = "PLAINTEXT";
        }
        if (!in_array(
            $signatureMethod,
            array_keys($this->signatureMethods)
        )
        ) {
            throw new Exception(
                "Signature method '$signatureMethod' not supported " .
                "try one of the following: " .
                implode(", ", array_keys($this->signatureMethods))
            );
        }
        return $this->signatureMethods[$signatureMethod];
    }
181639
private function getVersion($request)
    {
        $version = $request->getParameter("oauth_version");
        if (!$version) {
            $version = 1.0;
        }
        if ($version && $version != $this->version) {
            throw new Exception("OAuth version '$version' not supported");
        }
        return $version;
    }
711128
public function requestToken(Request $request)
    {
        $client = $this->getClient($request);

        /** @var TokenInterface $accessToken */
        $accessToken = $this->accessTokenRepository->findOneByClientWithoutUser($client);

        if (is_null($accessToken) || $accessToken->isBlocked() || $accessToken->isExpired()) {
            /** @var OrchestraTokenInterface $accessToken */
            $accessToken = $this->accessTokenManager->create($client);
            if (!$accessToken->isValid($this->validator)) {
                return $accessToken->getViolations();
            }

            $this->accessTokenManager->save($accessToken);
        }

        $tokenFacade = new AccessTokenFacade();
        $tokenFacade->accessToken   = $accessToken->getCode();
        $tokenFacade->expiresAt     = $accessToken->getExpiredAt();
        $tokenFacade->refreshToken = $accessToken->getRefreshCode();

        return $tokenFacade;
    }
441569
public function getMyChats(Request $request){
        
        /** @var LoginHelper $loginHelper */
        $loginHelper = $this->container->get('sopinet_login_helper');
        try {
            $user = $loginHelper->getUser($request);
        } catch(Exception $e) {
            throw new Exception($e->getMessage());
        }

        $em = $this->container->get('doctrine.orm.default_entity_manager');

        /** @var ChatRepository $reChat */
        $reChat = $em->getRepository('SopinetChatBundle:Chat');

        $all = $reChat->findAll();

        $chats = array();

        /** @var Chat $chat */
        foreach ($all as $chat){

            if($chat->getChatMembers()->contains($user)){
                $chats [] = $chat;
            }
        }

        return $chats;
    }
879104
public function requestApiKeyAction(Request $request)
    {
        /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
        $dispatcher = $this->get('event_dispatcher');

        $credentials = [];
        if ($request->request->has('login')) {
            $credentials[$this->getPropertyName(ClassMetadata::LOGIN_PROPERTY)] = $request->request->get('login');
        }
        if ($request->request->has('password')) {
            $credentials[$this->getPropertyName(ClassMetadata::PASSWORD_PROPERTY)] = $request->request->get('password');
        }
        [$user, $exception] = $this->processAuthentication($credentials);

        /** @var OnAssembleResponseEvent $result */
        $result = $dispatcher->dispatch(
            Ma27ApiKeyAuthenticationEvents::ASSEMBLE_RESPONSE,
            new OnAssembleResponseEvent($user, $exception)
        );

        if (!$response = $result->getResponse()) {
            throw new HttpException(
                Response::HTTP_INTERNAL_SERVER_ERROR,
                'Cannot assemble the response!',
                $exception
            );
        }

        return $response;
    }
478546
public function parseRequest(Request $request)
    {
        try {
            $this->setPath($request->get('_route'));

            $this->setQuery($request->query->all());

            $this->setRouteParams($request->attributes->get('_route_params'));

            if ($request->get('page')) {
                $this->setCurrentPage((int)$request->get('page'));
            }

            if ($request->get('maxItems')) {
                $this->setNumberOfElementsPerPage((int)$request->get('maxItems'));
            }

        } catch (\Exception $e) {
            throw new \Exception ('The request provided is not a valid Request Object');
        }

        return $this;
    }
403480
protected function call($request)
    {
        if(!isset($request['query']))
        {
            $request['query'] = [];
        }

        $method  = 'GET';
        $headers = $this->getHeaders();
        $query   = http_build_query($request['query']);
        $url     = "{$this->domain}/{$request['route']}?$query";

        try {
            $request = $this->getClient()->request($method, $url, [
                'headers' => $headers
            ]);

            $response = $request->getBody()->getContents();

            return json_decode($response, true);

        } catch (RequestException $e) {
            $response = $e->getResponse();
            $response = json_decode($response, true);
            return $response;
        } catch (\Exception $e) {
            return ['error' => $e->getCode(), 'error_description' => $e->getMessage()];
        }
    }
659214
def get_jwt(self, request):
        
        try:
            authorization = request.authorization
        except ValueError:
            return None
        if authorization is None:
            return None
        authtype, token = authorization
        if authtype.lower() != self.auth_header_prefix.lower():
            return None
        return token
1199000
public function request(string $request): string
    {
        $request  = $this->preRequest($request);
        return $this->send($request);
    }
1098390
public static function getJwt($request)
    {
        $token = static::getJWTFromAuthHeader();
        if (empty($token)) {
            $token = $request->header('X_DREAMFACTORY_SESSION_TOKEN');
        }
        if (empty($token)) {
            $token = $request->input('session_token');
        }

        return $token;
    }
1168447
private function checkCsrfToken(Request $request)
    {
        if ($this->csrfTokenManager === null) {
            return;
        }

        $exception = new UnauthorizedException(
            'Missing or invalid CSRF token',
            $request->getMethod() . ' ' . $request->getPathInfo()
        );

        if (!$request->headers->has('X-CSRF-Token')) {
            throw $exception;
        }

        $csrfToken = new CsrfToken(
            $this->csrfTokenIntention,
            $request->headers->get('X-CSRF-Token')
        );

        if (!$this->csrfTokenManager->isTokenValid($csrfToken)) {
            throw $exception;
        }
    }