code: public function authenticate(TokenInterface $token)
      {
          $user = $this->userProvider->loadUserByApiKey($this->encoder->encodePassword($token->getCredentials()));
  
          if (!$user || !($user instanceof UserInterface)) {
              throw new AuthenticationException('Bad credentials');
          }
  
          $token = new ApiKeyToken($token->getCredentials(), $user->getRoles());
          $token->setUser($user);
  
          return $token;
      }
docs: Authenticate the user based on an API key
  
  @param TokenInterface $token