src/Adapter/TokenBearerAdapter.php
public function initialize(ServerRequestInterface $request)
    {
        if (!$request->hasHeader('Authorization')) {
            return null;
        }

        $authorization = $request->getHeaderLine('Authorization');

        if (empty($authorization) || substr($authorization, 0, 6) !== 'Bearer') {
            return null;
        }

        $token_id = trim(substr($authorization, 7));

        if ($token_id === null || $token_id === '') {
            throw new InvalidTokenException();
        }

        if ($token = $this->token_repository->getById($token_id)) {
            if ($user = $token->getAuthenticatedUser($this->user_repository)) {
                $this->token_repository->recordUsageByToken($token);

                return new AuthenticationTransport($this, $user, $token);
            }
        }

        throw new InvalidTokenException();
    }
public function initialize(ServerRequestInterface $request)
    {
        if (!$request->hasHeader('Authorization')) {
            return null;
        }

        $authorization = $request->getHeaderLine('Authorization');

        if (empty($authorization) || substr($authorization, 0, 6) !== 'Bearer') {
            return null;
        }

        $token_id = trim(substr($authorization, 7));

        if ($token_id === null || $token_id === '') {
            throw new InvalidTokenException();
        }

        if ($token = $this->token_repository->getById($token_id)) {
            if ($user = $token->getAuthenticatedUser($this->user_repository)) {
                $this->token_repository->recordUsageByToken($token);

                return new AuthenticationTransport($this, $user, $token);
            }
        }

        throw new InvalidTokenException();
    }
{@inheritdoc}