function setupDocsClient($token = null) { global $authSubURL; $docsClient = null; // Fetch a new AuthSub token? if (!$token && !isset($_SESSION['sessionToken'])) { $next = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $scope = 'http://docs.google.com/feeds/ https://docs.google.com/feeds/'; $secure = 0; $session = 1; $permission = 1; // 1 - allows posting notices && allows reading profile data $authSubURL = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); } else { if (isset($_SESSION['sessionToken'])) { $httpClient = new Zend_Gdata_HttpClient(); $httpClient->setAuthSubToken($_SESSION['sessionToken']); $docsClient = new Zend_Gdata_Docs($httpClient, 'google-OCRPHPDemo-v0.1'); } else { $httpClient = new Zend_Gdata_HttpClient(); $_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken(trim($token), $httpClient); $httpClient->setAuthSubToken($_SESSION['sessionToken']); $docsClient = new Zend_Gdata_Docs($httpClient, 'google-OCRPHPDemo-v0.1'); } } return $docsClient; }
function getAuthSubUrl() { $next = getCurrentUrl(); $scope = 'http://picasaweb.google.com/data'; $secure = 0; $session = 1; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
/** * Returns the URL which the user must visit to authenticate * * @return void */ protected function _getAuthSubUrl() { $next = 'https://' . $this->_request->getHttpHost() . $this->_request->getRequestUri(); $scope = 'https://www.google.com/calendar/feeds/'; $secure = true; $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
function getAuthSubUrl() { $next = getCurrentUrl(); $scope = 'https://picasaweb.google.com/lh/myphotos?noredirect=1'; $secure = 0; $session = 1; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
/** * Returns the AuthSub URL which the user must visit to authenticate requests * from this application. * * Uses getCurrentUrl() to get the next URL which the user will be redirected * to after successfully authenticating with the Google service. * * @return string AuthSub URL */ function getAuthSubUrl() { $next = getCurrentUrl(); $scope = 'http://www.google.com/base/feeds/'; $secure = false; $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
/** * Logs in via AuthSub. AuthSub is simiar to OAuth, but was developed * before OAuth became the "standard". AuthSub acts in a similar way as * OAuth. You login through Google, granting access to the site. You are * then returned to the site with an access token to authorize with. * * @param String $redirectUrl - URL that you want to redirect to * once a token is assigned * @return String - URL to follow to log into Google Calendar */ function getAuthSubUrl($redirectUrl) { // indicates the app will only access Google Calendar feeds $scope = 'http://www.google.com/calendar/feeds'; $secure = false; // if you are registered with SubAuth, then this can be true $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($redirectUrl, $scope, $secure, $session); }
public function testGetAuthSubTokenUriModifiedBase() { $uri = Zend_Gdata_AuthSub::getAuthSubTokenUri('http://www.example.com/foo.php', 'http://www.google.com/calendar/feeds', 0, 1, 'http://www.otherauthservice.com/accounts/AuthSubRequest'); // Note: the scope here is not encoded. It should be encoded, // but the method getAuthSubTokenUri calls urldecode($scope). // This currently works (no reported bugs) as web browsers will // handle the encoding in most cases. $this->assertEquals('http://www.otherauthservice.com/accounts/AuthSubRequest?next=http%3A%2F%2Fwww.example.com%2Ffoo.php&scope=http://www.google.com/calendar/feeds&secure=0&session=1', $uri); }
function generateSubTokenUrl($nextUrl = null) { $secure = false; $session = true; if (!$nextUrl) { $nextUrl = OPERATIONS_URL; } $url = Zend_Gdata_AuthSub::getAuthSubTokenUri($nextUrl, GDATA_SCOPE, $secure, $session); return $url; }
/** * Returns the AuthSub URL which the user must visit to authenticate requests * from this application. * * Uses getCurrentUrl() to get the next URL which the user will be redirected * to after successfully authenticating with the Google service. * * @return string AuthSub URL */ public function getAuthSubUrl() { global $_authSubKeyFile; $next = $this->getCurrentUrl(); $scope = 'http://www.google.com/calendar/feeds/'; $session = true; if ($_authSubKeyFile != null) { $secure = true; } else { $secure = false; } return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
function generateAuthSubURL() { $next = 'http://localhost/test1.php'; $scope = 'https://www.google.com/h9/feeds'; $authSubHandler = 'https://www.google.com/h9/authsub'; $secure = 0; $session = 1; $authSubURL = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session, $authSubHandler); // 1 - allows posting notices && allows reading profile data $permission = 1; $authSubURL .= '&permission=' . $permission; return '<a href="' . $authSubURL . '">Click here to link your H9 Account</a>'; }
function _getAuthSubUrl() { if (!empty($this->subdomain)) { $next = 'http://' . $_SERVER["HTTP_HOST"] . '/' . 'signin/callback/'; } else { $next = $this->config->item('base_url') . 'signin/callback/'; } $scope = 'http://gdata.youtube.com http://picasaweb.google.com/data'; $secure = false; $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
public function getAuthSubUrl($args) { // Security check $this->throwForbiddenUnless(SecurityUtil::checkPermission('IWagendas::', '::', ACCESS_READ)); $next = ModUtil::func('IWagendas', 'user', 'getCurrentUrl'); $scope = 'http://www.google.com/calendar/feeds/'; $session = true; $secure = false; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
<?php require_once __MLC__ . '/google/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_YouTube'); Zend_Loader::loadClass('Zend_Gdata_YouTube_VideoQuery'); Zend_Loader::loadClass('Zend_Gdata_AuthSub'); Zend_Loader::loadClass('Zend_Gdata_App_Exception'); $scope = 'http://gdata.youtube.com'; $secure = false; $session = true; $nextUrl = 'http://' . $_SERVER['SERVER_NAME'] . __PHP_ASSETS__ . '/youtube/youtubeAuth.php'; $url = Zend_Gdata_AuthSub::getAuthSubTokenUri($nextUrl, $scope, $secure, $session); ?> <a href="<?php _p($url); ?> " target='_blank'> <strong>Click here to authenticate with YouTube</strong> </a>
function getAuthSubRequestUrl() { $next = "http://" . $_SERVER['SERVER_NAME'] . $this->base . "/yts/process/"; $scope = 'http://gdata.youtube.com'; $secure = false; $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
function getAuthSubRequestUrl() { // $next ='http://mmm.zeropoint.it/index.php/yts/index/'; $next = "http://" . $_SERVER['SERVER_NAME'] . $this->base . "/yts/index/"; $scope = 'http://gdata.youtube.com'; $secure = false; $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
/** * Get the URL for the AuthSub login page. * * @return string The URL */ function createLoginUrl() { $next = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['PHP_SELF']}"; $scope = 'http://gdata.youtube.com'; $secure = false; $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); }
* Google Base location */ $uri = Zend_Gdata_Base::BASE_FEED_URI; session_start(); if (!isset($_SESSION['base_token'])) { if (isset($_GET['token'])) { /** * Convert the single-use token to a session token. */ $session_token = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); $_SESSION['base_token'] = $session_token; } else { /** * Display a link to generate a single-use token. */ $googleUri = Zend_Gdata_AuthSub::getAuthSubTokenUri('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], $uri, 0, 1); echo "Click <a href='{$googleUri}'>here</a> to authorize this application."; exit; } } /** * Create an authenticated HTTP Client to talk to Google. */ $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['base_token']); /** * Submit query to Google Base */ $q = ''; if (isset($_GET['q']) && $_GET['q']) { $q = $_GET['q']; if (get_magic_quotes_gpc()) {
* You should have received a copy of the GNU General Public License * along with GCalendar. If not, see <http://www.gnu.org/licenses/>. * * @author Allon Moritz * @copyright 2007-2010 Allon Moritz * @since 2.2.0 */ defined('_JEXEC') or die('Restricted access'); $mainframe =& JFactory::getApplication(); $absolute_path = $mainframe->getCfg('absolute_path'); ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . JPATH_COMPONENT . DS . 'libraries'); require_once 'Zend' . DS . 'Loader.php'; Zend_Loader::loadClass('Zend_Gdata_AuthSub'); Zend_Loader::loadClass('Zend_Gdata_HttpClient'); Zend_Loader::loadClass('Zend_Gdata_Calendar'); $params =& JComponentHelper::getParams('com_gcalendar'); $domain = $params->get('google_apps_domain'); $u = JFactory::getURI(); $next = JRoute::_($u->toString() . '?option=com_gcalendar&task=' . JRequest::getCmd('nextTask')); $scope = 'http://www.google.com/calendar/feeds/'; $session = true; $secure = false; $hd = ''; if (!empty($domain)) { $hd = '&hd=' . $domain; } $authSubUrl = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session, Zend_Gdata_AuthSub::AUTHSUB_REQUEST_URI); echo "<a href=\"" . $authSubUrl . $hd . "\">Please Login to access the calendar data.</a>"; ?>
private function _getAuthSubClient() { if (!isset($_SESSION['sessionToken']) && !isset($_GET['token'])) { $request = $this->getRequest(); $nextUrl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getRequestUri(); $scope = 'http://www.google.com/base/feeds/items'; $secure = false; $session = true; $authSubUrl = Zend_Gdata_AuthSub::getAuthSubTokenUri($nextUrl, $scope, $secure, $session); header("HTTP/1.0 307 Temporary redirect"); header("Location: " . $authSubUrl); exit; } if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) { $_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); } $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']); return $client; }
/** * Return authenticated http client * * @param string $token * * @return \self * * @version 5.0 */ public static function getAuthSubHttpClient($token = false) { $next = elgg_get_site_url() . GLOBAL_IZAP_VIDEOS_PAGEHANDLER . '/upload/' . elgg_get_logged_in_user_entity()->username . '/youtube'; $scope = 'http://gdata.youtube.com'; $secure = false; $session = true; if (!isset($_SESSION['YT_TOKEN']) && !$token) { return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); } else { if (!isset($_SESSION['YT_TOKEN']) && $token) { $_SESSION['YT_TOKEN'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($token); } } return new self(Zend_Gdata_AuthSub::getHttpClient($_SESSION['YT_TOKEN']), izap_admin_settings_izap_videos('youtubeDeveloperKey')); }
function authenticate($singleUseToken = null) { $sessionToken = isset($_SESSION['sessionToken']) ? $_SESSION['sessionToken'] : null; // If there is no AuthSub session or one-time token waiting for us, // redirect the user to Google Health's AuthSub handler to get one. if (!$sessionToken && !$singleUseToken) { $next = getCurrentUrl(); $secure = 1; $session = 1; $authSubHandler = 'https://www.google.com/h9/authsub'; $permission = 1; // 1 - allows reading of the profile && posting notices $authSubURL = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, SCOPE, $secure, $session, $authSubHandler); $authSubURL .= '&permission=' . $permission; echo '<a href="' . $authSubURL . '">Link your Google Health Account</a>'; exit; } $client = new Zend_Gdata_HttpClient(); $client->setAuthSubPrivateKeyFile(HEALTH_PRIVATE_KEY, null, true); // Convert an AuthSub one-time token into a session token if needed if ($singleUseToken && !$sessionToken) { $sessionToken = Zend_Gdata_AuthSub::getAuthSubSessionToken($singleUseToken, $client); $_SESSION['sessionToken'] = $sessionToken; } $client->setAuthSubToken($sessionToken); return $client; }
public function googleAction() { //$this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $my_calendar = 'http://www.google.com/calendar/feeds/default/private/full'; if (!isset($_SESSION['cal_token'])) { if (isset($_GET['token'])) { // You can convert the single-use token to a session token. $session_token = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); // Store the session token in our session. $_SESSION['cal_token'] = $session_token; } else { // Display link to generate single-use token $googleUri = Zend_Gdata_AuthSub::getAuthSubTokenUri('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], $my_calendar, 0, 1); echo "Click <a href='{$googleUri}'>here</a> " . "to authorize this application."; exit; } } // Create an authenticated HTTP Client to talk to Google. $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['cal_token']); // Create a Gdata object using the authenticated Http Client $cal = new Zend_Gdata_Calendar($client); var_export($cal->getCalendarListFeed()->count()); }
} // メイン処理 if (!isset($_SESSION['cal_token'])) { if (isset($_GET['token'])) { // 認証後リダイレクトされたときはここに // single-use トークンをセッショントークンに変換 $session_token = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); // セッショントークンをセッションに保存 $_SESSION['cal_token'] = $session_token; } else { // 初回アクセス時はここになる $uriRedirect = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; //echo $uriRedirect; $uriCalendar = 'http://www.google.com/calendar/feeds/'; $hostedDomain = 'nexchie.com'; $uriGoogleAuth = Zend_Gdata_AuthSub::getAuthSubTokenUri($uriRedirect, $uriCalendar, 0, 1); header("Location: " . $uriGoogleAuth . "&hd=nexchie.com"); //echo $uriGoogleAuth; echo "<h1>Googleカレンダータイムシート</h1>"; echo "<a href='{$uriGoogleAuth}'>ログイン</a>"; } } if (isset($_SESSION['cal_token'])) { // 認証済みHTTPクライアント作成 $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['cal_token']); // Calendarサービスのインスタンス作成 $service = new Zend_Gdata_Calendar($client); $query = $service->newEventQuery(); $query->setUser('default'); // MagicCookie 認証の場合は // $query->setVisibility('private-magicCookieValue') とします
/** * Generate an AuthSub request Link and print it to the page. * * @param string $nextUrl URL to redirect to after performing the authentication. * @return void */ function generateAuthSubRequestLink($nextUrl = null) { $scope = 'http://gdata.youtube.com'; $secure = false; $session = true; if (!$nextUrl) { generateUrlInformation(); $nextUrl = $_SESSION['operationsUrl']; } $url = Zend_Gdata_AuthSub::getAuthSubTokenUri($nextUrl, $scope, $secure, $session); echo '<a href="' . $url . '"><strong>Click here to authenticate with YouTube</strong></a>'; }
/** * We arrive here when the user first comes to the form. The first step is * to have them get a single-use token. */ function showIntroPage() { $next_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $scope = ITEMS_FEED_URI; $secure = false; $session = true; $redirect_url = Zend_Gdata_AuthSub::getAuthSubTokenUri($next_url, $scope, $secure, $session); printHTMLHeader(); print '<table style="width:50%;">' . "\n" . '<tr>' . "\n" . '<th colspan="2" style="text-align:center;">' . 'PHP Demo: Google Base data API<br/>' . '<small><span style="font-variant: small-caps;">Powered By</span>' . ' <a href="http://framework.zend.com/download/gdata">' . 'Zend Google Data Client Library</a></small></th>' . "\n" . '</tr>' . "\n" . '<tr><td>Before you get started, please <a href="' . $redirect_url . '">sign in</a> to your personal Google Base account.</td></tr>' . "\n" . '</table>' . "\n"; printHTMLFooter(); }
public function action_import() { $this->template->content = "Muahhaa"; $my_calendar = 'http://www.google.com/calendar/feeds/default/private/full'; if (!isset($_SESSION['cal_token'])) { if (isset($_GET['token'])) { // You can convert the single-use token to a session token. $session_token = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); // Store the session token in our session. $_SESSION['cal_token'] = $session_token; } else { // Display link to generate single-use token $url = url::site('admin/import', TRUE); $googleUri = Zend_Gdata_AuthSub::getAuthSubTokenUri($url, $my_calendar, 0, 1); $this->template->content = "Click <a href='{$googleUri}'>here</a> to authorize this application."; return; } } // Create an authenticated HTTP Client to talk to Google. $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['cal_token']); // Create a Gdata object using the authenticated Http Client $this->cal = new Zend_Gdata_Calendar($client); $this->template->content = ""; if (isset($_POST['selectedCalendar'])) { $_SESSION['selectedCal'] = $_POST['selectedCalendar']; } $this->_fetchCalendarCache(); $this->importSelectCal(); if ($_SESSION['selectedCal']) { $this->_fetchEventsCache($_SESSION['selectedCal']); $this->template->content .= View::factory('admin/import_calEvents', array('events' => $_SESSION['eventsCache'][$_SESSION['selectedCal']], 'existingRooms' => ORM::factory('room')->find_all()->as_array())); } }
/** * displayEditPicasa * * @return void */ function displayEditPicasa() { $this->displayHeader(); $token = getUserPicasaSessionToken($this->fcmsUser->id); // Setup url for callbacks $callbackUrl = getDomainAndDir(); $callbackUrl .= 'settings.php?view=picasa'; if (!is_null($token)) { $httpClient = Zend_Gdata_AuthSub::getHttpClient($token); $picasaService = new Zend_Gdata_Photos($httpClient, "Google-DevelopersGuide-1.0"); try { $feed = $picasaService->getUserFeed("default"); } catch (Zend_Gdata_App_Exception $e) { print '<div class="error-alert">' . T_('Could not get Picasa session token.') . '</div>'; return; } $username = $feed->getTitle(); $user = '******' . $username . '">' . $username . '</a>'; $status = sprintf(T_('Currently connected as: %s'), $user); $link = '<a class="disconnect" href="?revoke=picasa">' . T_('Disconnect') . '</a>'; } else { $url = Zend_Gdata_AuthSub::getAuthSubTokenUri($callbackUrl, 'https://picasaweb.google.com/data', false, true); $status = T_('Not Connected'); $link = '<a href="' . $url . '">' . T_('Connect') . '</a>'; } echo ' <div class="social-media-connect"> <img class="icon" src="ui/img/picasa.png" alt="Picasa"/> <h2>Picasa Web</h2> <p>' . T_('Picasa Web allows users to share photos with friends and family.') . '</p> <div class="status">' . $status . '</div> <div class="action">' . $link . '</div> </div>'; $this->displayFooter(); }