Example #1
0
 /**
  * {@inheritdoc}
  */
 public function authenticate(TokenInterface $token)
 {
     if (!$this->supports($token)) {
         return null;
     }
     if ($this->serverService->validateRequest($token->getRequestParameters(), $token->getRequestMethod(), $token->getRequestUrl())) {
         $params = $token->getRequestParameters();
         $accessToken = $this->tokenProvider->loadAccessTokenByToken($params['oauth_token']);
         $user = $accessToken->getUser();
         if (null !== $user) {
             $token->setUser($user);
             return $token;
         }
     }
     throw new AuthenticationException('OAuth authentification failed');
 }