apiTokenRepository->findOneBy(['token' => $accessToken]); if(!$token) { throw new BadCredentialsException(); } if(!$token->isValid()) { throw new CustomUserMessageAuthenticationException('Token expired'); } $token->getOwnedBy()->markAsTokenAuthenticated($token->getScopes()); return new UserBadge($token->getOwnedBy()->getUserIdentifier()); } }