Example #1
0
 public function doGetCallback(Application $app, Request $request, $api_name)
 {
     $error_message = '';
     try {
         $api = \Bridge_Api::get_by_api_name($app, $api_name);
         $connector = $api->get_connector();
         $response = $connector->connect();
         $user_id = $connector->get_user_id();
         try {
             $account = \Bridge_Account::load_account_from_distant_id($app, $api, $app['authentication']->getUser(), $user_id);
         } catch (\Bridge_Exception_AccountNotFound $e) {
             $account = \Bridge_Account::create($app, $api, $app['authentication']->getUser(), $user_id, $connector->get_user_name());
         }
         $settings = $account->get_settings();
         if (isset($response['auth_token'])) {
             $settings->set('auth_token', $response['auth_token']);
         }
         if (isset($response['refresh_token'])) {
             $settings->set('refresh_token', $response['refresh_token']);
         }
         $connector->set_auth_settings($settings);
         $connector->reconnect();
     } catch (\Exception $e) {
         $error_message = $e->getMessage();
     }
     $params = ['error_message' => $error_message];
     return $app['twig']->render('prod/actions/Bridge/callback.html.twig', $params);
 }
Example #2
0
 public function setUp()
 {
     parent::setUp();
     try {
         self::$api = \Bridge_Api::get_by_api_name(self::$DI['app'], 'apitest');
     } catch (\Bridge_Exception_ApiNotFound $e) {
         self::$api = \Bridge_Api::create(self::$DI['app'], 'apitest');
     }
     try {
         self::$account = \Bridge_Account::load_account_from_distant_id(self::$DI['app'], self::$api, self::$DI['user'], 'kirikoo');
     } catch (\Bridge_Exception_AccountNotFound $e) {
         self::$account = \Bridge_Account::create(self::$DI['app'], self::$api, self::$DI['user'], 'kirikoo', 'coucou');
     }
 }
Example #3
0
 public function bootTestCase()
 {
     $application = self::$DI['app'];
     try {
         self::$api = Bridge_Api::get_by_api_name($application, 'apitest');
     } catch (Bridge_Exception_ApiNotFound $e) {
         self::$api = Bridge_Api::create($application, 'apitest');
     }
     try {
         self::$account = Bridge_Account::load_account_from_distant_id($application, self::$api, self::$DI['user'], 'kirikoo');
     } catch (Bridge_Exception_AccountNotFound $e) {
         self::$account = Bridge_Account::create($application, self::$api, self::$DI['user'], 'kirikoo', 'coucou');
     }
 }
Example #4
0
 public function setUp()
 {
     parent::setUp();
     $this->auth = $this->getMock("Bridge_Api_Auth_Interface");
     $this->bridgeApi = $this->getMock('Bridge_Api_Abstract', ["is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"], [self::$DI['app']['url_generator'], self::$DI['app']['conf'], $this->auth, self::$DI['app']['translator']]);
     if (!self::$api) {
         $application = $this->getApplication();
         try {
             self::$api = Bridge_Api::get_by_api_name($application, 'apitest');
         } catch (Bridge_Exception_ApiNotFound $e) {
             self::$api = Bridge_Api::create($application, 'apitest');
         }
         try {
             self::$account = Bridge_Account::load_account_from_distant_id($application, self::$api, self::$DI['user'], 'kirikoo');
         } catch (Bridge_Exception_AccountNotFound $e) {
             self::$account = Bridge_Account::create($application, self::$api, self::$DI['user'], 'kirikoo', 'coucou');
         }
     }
 }