コード例 #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');
 }
コード例 #2
0
 /**
  * Exchange a request token for an access token.
  * OAuth v1.0
  */
 public function accessTokenAction(Request $request)
 {
     $data = $this->serverService->accessToken($request->attributes->get('oauth_request_parameters'), $request->attributes->get('oauth_request_method'), $request->attributes->get('oauth_request_url'));
     return $this->sendResponse($data);
 }