Example #1
0
 public function action_auth()
 {
     $this->layout->scripts = array('sourcemap-core', 'sourcemap-template', 'sourcemap-working', 'sourcemap-upload');
     $this->layout->styles = array('assets/styles/style.css', 'assets/styles/sourcemap.less');
     if (isset($_GET['oauth_token'], $_GET['oauth_verifier']) && ($secret = Session::instance()->get('g_oauth_token_secret'))) {
         $auth_tok = array('oauth_token' => $_GET['oauth_token'], 'oauth_verifier' => $_GET['oauth_verifier'], 'oauth_token_secret' => $secret);
     } else {
         Message::instance()->set('Invalid OAuth token or identifier. Try again.');
         $this->redirect('/tools/import/google/');
     }
     $oauth = Google_Oauth::factory(Google_Oauth::SPREADSHEETS);
     $acc_token = $oauth->get_acc_token($auth_tok);
     Session::instance()->set('g_oauth_access_token', $acc_token);
     $this->request->redirect('/tools/import/google/list');
 }
Example #2
0
 public function action_auth()
 {
     $this->layout->scripts = array('sourcemap-core', 'sourcemap-template', 'sourcemap-working', 'sourcemap-upload');
     $this->layout->styles = array('assets/styles/style.css', 'assets/styles/sourcemap.less');
     if (isset($_GET['oauth_token'], $_GET['oauth_verifier']) && ($secret = Session::instance()->get('oauth_token_secret'))) {
         $auth_tok = array('oauth_token' => $_GET['oauth_token'], 'oauth_verifier' => $_GET['oauth_verifier'], 'oauth_token_secret' => $secret);
     } else {
         throw new Exception('Invalid token/verifier.');
     }
     $oauth = Google_Oauth::factory(Google_Oauth::SPREADSHEETS);
     $acc_token = $oauth->get_acc_token($auth_tok);
     $url = "https://spreadsheets.google.com/feeds/cells/0Aqwz6ZHrexb7dHNBa0tsVDhlX1N5MkVrV3FxczE2cmc/od6/private/full";
     $oauth_header = $oauth->get_token_auth_header($acc_token, $url);
     $headers = array();
     $headers = array('Authorization' => $oauth_header);
     $response = Sourcemap_Http_Client::do_get($url, null, $headers);
     $data = $response;
 }
 public static function get_list($oauth_acc_token)
 {
     $oauth = Google_Oauth::factory(Google_Oauth::SPREADSHEETS);
     $url = self::URL_BASE . self::URL_LIST;
     $oauth_header = $oauth->get_token_auth_header($oauth_acc_token, $url);
     $response = Sourcemap_Http_Client::do_get($url, null, array('Authorization' => $oauth_header));
     if (!$response->status_ok()) {
         throw new Exception('Could not authorize.');
     }
     return self::parse_list($response->body);
 }