load->library('Google_Sync'); header('Location: ' . $this->google_sync->get_auth_url()); } /** * Callback method for the Google Calendar API authorization process. * * Once the user grants consent with his Google Calendar data usage, the Google * OAuth service will redirect him back in this page. Here we are going to store * the refresh token, because this is what will be used to generate access tokens * in the future. * * IMPORTANT! Because it is necessary to authorize the application * using the web server flow (see official documentation of OAuth), every * Easy!Appointments installation should use its own calendar api key. So in every * api console account, the "http://path-to-e!a/google/oauth_callback" should be * included in an allowed redirect url. */ public function oauth_callback() { if (isset($_GET['code'])) { $this->load->library('Google_Sync'); $token = $this->google_sync->authenticate($_GET['code']); // Store the token into the database for future reference. if (!isset($_SESSION)) { @session_start(); } if (isset($_SESSION['oauth_provider_id'])) { $this->load->model('Providers_Model'); $this->Providers_Model->set_setting('google_sync', TRUE, $_SESSION['oauth_provider_id']); $this->Providers_Model->set_setting('google_token', $token, $_SESSION['oauth_provider_id']); } else { echo '