/** * Get user authorization. * OAuth v1.0 */ public function authorizeAction(Request $request) { $oauth_token = $request->get('oauth_token', null); $oauth_callback = $request->get('oauth_callback', null); $token = $this->serverService->getTokenProvider()->loadRequestTokenByToken($oauth_token); if (!$token instanceof RequestTokenInterface) { throw new HttpException(404); } if ('GET' === $request->getMethod()) { // redirect to the secured 'allow' page return new RedirectResponse($this->router->generate('bazinga_oauth_login_allow', array('oauth_token' => $oauth_token, 'oauth_callback' => $oauth_callback))); } if (false !== $request->request->get('submit_true')) { $authorizeString = $this->serverService->authorize($oauth_token, $oauth_callback); if ('http' === substr($authorizeString, 0, 4)) { return new RedirectResponse($authorizeString, 302); } else { return $this->sendResponse($authorizeString); } } $this->serverService->getTokenProvider()->deleteRequestToken($token); // error page if the user didn't accept to share its information. return new Response($this->engine->render('BazingaOAuthServerBundle::error.html.twig', array('consumer' => $token->getConsumer()))); }
/** * @param UserProviderInterface $userProvider The user provider. * @param OAuthServerServiceInterface $serverService The OAuth server service. */ public function __construct(UserProviderInterface $userProvider, OAuthServerServiceInterface $serverService) { $this->userProvider = $userProvider; $this->serverService = $serverService; $this->tokenProvider = $serverService->getTokenProvider(); }