Security/Guard/JWTTokenAuthenticator.php
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;
    }
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;
    }
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 ; }
Returns a decoded JWT token extracted from a request.

{@inheritdoc}

@return PreAuthenticationJWTUserToken

@throws InvalidTokenException If an error occur while decoding the token
@throws ExpiredTokenException If the request token is expired
Returns a decoded JWT token extracted from a request .