/** * {@inheritDoc} */ protected function attemptAuthentication(Request $request) { $this->handleOAuthError($request); /* @var ResourceOwnerInterface $resourceOwner */ list($resourceOwner, $checkPath) = $this->resourceOwnerMap->getResourceOwnerByRequest($request); if (!$resourceOwner) { throw new AuthenticationException('No resource owner match the request.'); } if (!$resourceOwner->handles($request)) { throw new AuthenticationException('No oauth code in the request.'); } // If resource owner supports only one url authentication, call redirect if ($request->query->has('authenticated') && $resourceOwner->getOption('auth_with_one_url')) { $request->attributes->set('service', $resourceOwner->getName()); return new RedirectResponse(sprintf('%s?code=%s&authenticated=true', $this->httpUtils->generateUri($request, 'hwi_oauth_connect_service'), $request->query->get('code'))); } $resourceOwner->isCsrfTokenValid($request->get('state')); try { $accessToken = $resourceOwner->getAccessToken($request, $this->httpUtils->createRequest($request, $checkPath)->getUri()); } catch (HttpTransportException $e) { throw new AuthenticationException('Cannot retrieve access token.'); } $token = new OAuthToken($accessToken); $token->setResourceOwnerName($resourceOwner->getName()); return $this->authenticationManager->authenticate($token); }
/** * {@inheritDoc} */ protected function attemptAuthentication(Request $request) { list($resourceOwner, $checkPath) = $this->resourceOwnerMap->getResourceOwnerByRequest($request); $accessToken = $resourceOwner->getAccessToken($request->query->get('code'), $this->httpUtils->createRequest($request, $checkPath)->getUri()); $token = new OAuthToken($accessToken); $token->setResourceOwnerName($resourceOwner->getName()); return $this->authenticationManager->authenticate($token); }
/** * {@inheritDoc} */ protected function attemptAuthentication(Request $request) { $this->handleOAuthError($request); list($resourceOwner, $checkPath) = $this->resourceOwnerMap->getResourceOwnerByRequest($request); if (!$resourceOwner->handles($request)) { throw new AuthenticationException('No oauth code in the request.'); } $accessToken = $resourceOwner->getAccessToken($request, $this->httpUtils->createRequest($request, $checkPath)->getUri()); $token = new OAuthToken($accessToken); $token->setResourceOwnerName($resourceOwner->getName()); return $this->authenticationManager->authenticate($token); }
/** * {@inheritDoc} */ protected function attemptAuthentication(Request $request) { list($resourceOwner, $checkPath) = $this->resourceOwnerMap->getResourceOwnerByRequest($request); if (!$resourceOwner->handles($request)) { // Can't use AuthenticationException below, as it leads to infinity loop throw new \RuntimeException('No oauth code in the request.'); } $accessToken = $resourceOwner->getAccessToken($request, $this->httpUtils->createRequest($request, $checkPath)->getUri()); $token = new OAuthToken($accessToken); $token->setResourceOwnerName($resourceOwner->getName()); return $this->authenticationManager->authenticate($token); }