/** * {@inheritDoc} */ public function authenticate(TokenInterface $token) { $user = $this->userProvider->loadUserByUsername($token->getUsername()); if ($user) { $authenticatedToken = new OAuthToken($user->getRoles(), $token->getResponse()); $authenticatedToken->setAuthenticated(true); $authenticatedToken->setUser($user); return $authenticatedToken; } throw new AuthenticationException('OAuth Authentication Failed.'); }