/**
  * Function to Grant Access to Linkedin
  * @author Rohan Julka
  * */
 public function linkedInLogin($userIdApp = null)
 {
     $userId = !empty($userIdApp) ? $userIdApp : $this->Session->read('Auth.Front.id');
     $userIsConnected = $this->User->find('first', array('conditions' => array('User.id' => array($this->Encryption->decode($userId))), 'fields' => array('User.linkedin_connected')));
     if (!empty($userIsConnected['User']['linkedin_connected'])) {
         $this->Session->setFlash('Your LinkedIn account has already been linked', 'Front/flash_good');
         if (!empty($userIdApp)) {
             $this->redirect('foxhoprapplication://alreadylinkedin');
         } else {
             return $this->redirect(array('controller' => 'businessOwners', 'action' => 'social', 'linkedIn'));
         }
     }
     if (!empty($userIdApp)) {
         $this->Session->write('Auth.Front.id', $userIdApp);
         $this->Session->write('AccessedBy', 'WebService');
     }
     require_once ROOT . DS . APP_DIR . DS . 'Plugin/linkedin/linkedin.php';
     $ln = new LinkedIn(Configure::read('linkedinApiKey'), Configure::read('linkedinApiSecret'), Configure::read('SITE_URL') . 'businessOwners/linkedInOauthCallback', array('w_share', 'r_basicprofile'));
     if ($ln->authorize()) {
         $ln->resetToken();
         $ln->authorize();
         echo 'authorized';
     } else {
         echo 'not authorized';
     }
     $this->autoRender = false;
 }