Controller/AdminController.php
public function returnAction(Request $request)
    {
        $name = $request->getSession()->get(self::SESSION_KEY, null);

        /* @var \Google_Client $client */
        $clientProvider = $this->get('happyr.google_site_authenticator.client_provider');
        $client = $clientProvider->getClient($name);

        $flashBag = $this->get('session')->getFlashbag();
        if ($request->query->has('code')) {
            try {
                $client->authenticate($request->query->get('code'));
                $clientProvider->setAccessToken($client->getAccessToken(), $name);

                $flashBag->add('msg', 'Successfully authenticated!');
            } catch (\Google_Auth_Exception $e) {
                $flashBag->add('error', $e->getMessage());
            }
        } else {
            $flashBag->add('error', 'Authentication aborted.');
        }

        return $this->redirect($this->generateUrl('happyr.google_site_authenticator.index'));
    }
public function returnAction(Request $request)
    {
        $name = $request->getSession()->get(self::SESSION_KEY, null);

        /* @var \Google_Client $client */
        $clientProvider = $this->get('happyr.google_site_authenticator.client_provider');
        $client = $clientProvider->getClient($name);

        $flashBag = $this->get('session')->getFlashbag();
        if ($request->query->has('code')) {
            try {
                $client->authenticate($request->query->get('code'));
                $clientProvider->setAccessToken($client->getAccessToken(), $name);

                $flashBag->add('msg', 'Successfully authenticated!');
            } catch (\Google_Auth_Exception $e) {
                $flashBag->add('error', $e->getMessage());
            }
        } else {
            $flashBag->add('error', 'Authentication aborted.');
        }

        return $this->redirect($this->generateUrl('happyr.google_site_authenticator.index'));
    }
public function returnAction ( Request $ request ) { $ name = $ request -> getSession ( ) -> get ( self :: SESSION_KEY , null ) ; /* @var \Google_Client $client */ $ clientProvider = $ this -> get ( 'happyr.google_site_authenticator.client_provider' ) ; $ client = $ clientProvider -> getClient ( $ name ) ; $ flashBag = $ this -> get ( 'session' ) -> getFlashbag ( ) ; if ( $ request -> query -> has ( 'code' ) ) { try { $ client -> authenticate ( $ request -> query -> get ( 'code' ) ) ; $ clientProvider -> setAccessToken ( $ client -> getAccessToken ( ) , $ name ) ; $ flashBag -> add ( 'msg' , 'Successfully authenticated!' ) ; } catch ( \ Google_Auth_Exception $ e ) { $ flashBag -> add ( 'error' , $ e -> getMessage ( ) ) ; } } else { $ flashBag -> add ( 'error' , 'Authentication aborted.' ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'happyr.google_site_authenticator.index' ) ) ; }
This action is used when the user has authenticated with google.

@param Request $request

@return Response
This action is used when the user has authenticated with google .