public function authenticate(TokenInterface $token)
 {
     try {
         $localUser = $this->userProvider->loadUserByUsername($token->getUser());
         $authorizedToken = new ConnectToken($localUser, $token->getAccessToken(), $token->getApiUser(), $this->providerKey, $token->getScope(), $localUser->getRoles());
         $authorizedToken->setAttributes($token->getAttributes());
         return $authorizedToken;
     } catch (\Exception $repositoryProblem) {
         throw new AuthenticationServiceException($repositoryProblem->getMessage(), $token, 0, $repositoryProblem);
     }
 }
 public function authenticate(TokenInterface $token)
 {
     try {
         $localUser = $this->userProvider->loadUserByUsername($token->getUser());
         $authorizedToken = new ConnectToken($localUser, $token->getAccessToken(), $token->getApiUser(), $this->providerKey, $token->getScope(), $localUser->getRoles());
         $authorizedToken->setAttributes($token->getAttributes());
         return $authorizedToken;
     } catch (\Exception $repositoryProblem) {
         if (!method_exists('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationServiceException', 'setToken')) {
             throw new AuthenticationServiceException($repositoryProblem->getMessage(), $token, 0, $repositoryProblem);
         } else {
             $e = new AuthenticationServiceException($repositoryProblem->getMessage(), 0, $repositoryProblem);
             $e->setToken($token);
             throw $e;
         }
     }
 }