当前位置: 首页>>代码示例>>PHP>>正文


PHP Google_Client::revokeToken方法代码示例

本文整理汇总了PHP中Google_Client::revokeToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_Client::revokeToken方法的具体用法?PHP Google_Client::revokeToken怎么用?PHP Google_Client::revokeToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Google_Client的用法示例。


在下文中一共展示了Google_Client::revokeToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: revokeToken

 public function revokeToken()
 {
     $this->client->revokeToken();
     $this->accessToken = '';
     $this->refreshToken = '';
     $this->settings['googledrive_app_current_token'] = '';
     $this->settings['googledrive_app_refresh_token'] = '';
     update_option('use_your_drive_lists', array());
     update_option('use_your_drive_cache', array('last_update' => null, 'last_cache_id' => '', 'locked' => false, 'cache' => ''));
     update_option('use_your_drive_settings', $this->settings);
     return true;
 }
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:12,代码来源:UseyourDrive.php

示例2: signin

 public function signin()
 {
     $client = new \Google_Client();
     $client->setClientId(Config::get('ntentan:social.google.client_id'));
     $client->setClientSecret(Config::get('ntentan:social.google.client_secret'));
     $client->setRedirectUri(Config::get('ntentan:social.google.redirect_uri'));
     $client->addScope(array('profile', 'email'));
     $oauth2 = new \Google_Service_Oauth2($client);
     if (isset($_REQUEST['logout'])) {
         Session::set('access_token', '');
         $client->revokeToken();
     }
     if (isset($_GET['code'])) {
         $client->authenticate($_GET['code']);
         Session::set('access_token', $client->getAccessToken());
         Redirect::path(\ntentan\Router::getRoute());
     }
     if (isset($_SESSION['access_token'])) {
         $client->setAccessToken($_SESSION['access_token']);
     }
     if ($client->isAccessTokenExpired()) {
         $authUrl = $client->createAuthUrl();
         header('Location: ' . filter_var($authUrl, FILTER_SANITIZE_URL));
     }
     if ($client->getAccessToken()) {
         $user = $oauth2->userinfo->get();
         $_SESSION['token'] = $client->getAccessToken();
         return array('firstname' => $user['given_name'], 'lastname' => $user['family_name'], 'key' => "google_{$user['id']}", 'avatar' => $user['picture'], 'email' => $user['email'], 'email_confirmed' => $user['verified_email']);
     } else {
         header("Location: {$client->createAuthUrl()}");
         die;
     }
     return false;
 }
开发者ID:ntentan,项目名称:social-extension,代码行数:34,代码来源:GoogleSignin.php

示例3: logout

 public function logout($token)
 {
     $client = new Google_Client();
     $token = base64_decode($token);
     $client->setAccessToken($token);
     return $client->revokeToken();
 }
开发者ID:M7ammed,项目名称:Mobile-Judge-App,代码行数:7,代码来源:Students.php

示例4: disconnect

 /**
  * Permet de déconnecter la personne de son compte Google
  * @param User $user
  * @return bool
  */
 public function disconnect(User $user)
 {
     if (null != $this->client->getAccessToken()) {
         $tokenObject = json_decode($this->client->getAccessToken());
         $token = $tokenObject->access_token;
         $response = $this->client->revokeToken($token);
         if (true !== $response) {
             return false;
         }
     }
     $session = new Session();
     $session->remove('access_token');
     $user->setGoogleRefreshToken(null);
     //     $this->googleCalendarManager->removeAllGoogleCalendar($user);
     $this->em->flush();
     return true;
 }
开发者ID:GregHubs,项目名称:GestionRessources,代码行数:22,代码来源:GoogleServiceManager.php

示例5: GoogleUser

 public function GoogleUser()
 {
     $client = new \Google_Client();
     $client->setApplicationName(\SKT_GOOGLEOAUTH2_SETAPPLICATIONNAME);
     // Visit https://code.google.com/apis/console?api=plus to generate your
     // oauth2_client_id, oauth2_client_secret, and to register your oauth2_redirect_uri.
     $client->setClientId(\SKT_GOOGLEOAUTH2_SETCLIENTID);
     $client->setClientSecret(\SKT_GOOGLEOAUTH2_SETCLIENTSECRET);
     $client->setRedirectUri(\SKT_GOOGLEOAUTH2_SETREDIRECTURI);
     $client->setDeveloperKey(\SKT_GOOGLEOAUTH2_SETDEVELOPERKEY);
     $oauth2 = new \Google_Oauth2Service($client);
     if (isset($_GET['code'])) {
         $client->authenticate($_GET['code']);
         $_SESSION['token'] = $client->getAccessToken();
         $redirect = \SITE_SERVER;
         \CmsDev\Header\refresh::refreshNow(\filter_var($redirect, FILTER_SANITIZE_URL));
         return;
     }
     if (isset($_SESSION['token'])) {
         $client->setAccessToken($_SESSION['token']);
     }
     if (isset($_REQUEST['logout']) or \THIS_URL_REAL === 'UserLogout') {
         unset($_SESSION['token']);
         $client->revokeToken();
     }
     if ($client->getAccessToken()) {
         $user = $oauth2->userinfo->get();
         // These fields are currently filtered through the PHP sanitize filters.
         // See http://www.php.net/manual/en/filter.filters.sanitize.php
         $this->family_name = filter_var($user['family_name'], \FILTER_SANITIZE_STRING);
         $this->name = filter_var($user['name'], \FILTER_SANITIZE_STRING);
         $this->locale = filter_var($user['locale'], \FILTER_SANITIZE_STRING);
         $this->gender = filter_var($user['gender'], \FILTER_SANITIZE_STRING);
         $this->email = filter_var($user['email'], \FILTER_SANITIZE_EMAIL);
         $this->link = filter_var($user['link'], \FILTER_SANITIZE_URL);
         $this->given_name = filter_var($user['given_name'], \FILTER_SANITIZE_STRING);
         $this->id = filter_var($user['id'], \FILTER_SANITIZE_STRING);
         $this->verified_email = filter_var($user['verified_email'], \FILTER_SANITIZE_STRING);
         if (isset($user['picture']) && $user['picture'] != '') {
             $this->picture = filter_var($user['picture'], \FILTER_VALIDATE_URL);
         } else {
             $this->picture = \SKT_ACCESS_AVATAR;
         }
         $this->ClientAuth = 'Google';
         $_SESSION['token'] = $client->getAccessToken();
         $this->createAuthUrl = $client->createAuthUrl();
         $this->Info = array('family_name' => HtmlSpecialChars($this->family_name), 'name' => HtmlSpecialChars($this->name), 'locale' => $this->locale, 'gender' => $this->gender, 'email' => $this->email, 'link' => $this->link, 'given_name' => HtmlSpecialChars($this->given_name), 'id' => $this->id, 'verified_email' => $this->verified_email, 'picture' => $this->picture, 'ClientAuth' => $this->ClientAuth, 'createAuthUrl' => $this->createAuthUrl);
         \CmsDev\Security\UserRegister::checkAction($this->Info);
         return true;
     } else {
         $this->createAuthUrl = $client->createAuthUrl();
         new \CmsDev\Url\refer();
         return false;
     }
 }
开发者ID:neruruguay,项目名称:neru,代码行数:55,代码来源:oauth.php

示例6: logoutByStaffId

 /**
  * @param $staff_id
  * @return mixed
  */
 public function logoutByStaffId($staff_id)
 {
     $staff = new AB_Staff();
     $staff->load($staff_id);
     try {
         $this->loadByStaff($staff);
         $this->client->revokeToken();
     } catch (Exception $e) {
         $this->errors[] = $e->getMessage();
     }
     $staff->set('google_data', null);
     $staff->set('google_calendar_id', null);
     $staff->save();
     return $staff->get('id');
 }
开发者ID:patrickcurl,项目名称:monks,代码行数:19,代码来源:AB_Google.php

示例7: revokeToken

 /**
  * Revokes an authorization token. This both revokes the token by making a
  * Google Accounts API request to revoke the token as well as deleting the
  * token from the storage mechanism. If any errors occur, the authorization
  * exception is caught and the message is stored in error.
  */
 public function revokeToken()
 {
     $accessToken = $this->storage->get();
     if ($accessToken) {
         $tokenObj = json_decode($accessToken);
         try {
             $this->client->revokeToken($tokenObj->refresh_token);
             $this->storage->delete();
         } catch (Google_AuthException $e) {
             $this->errorMsg = $e->getMessage();
         }
     }
     // Keep things pretty. Removes the auth code from the URL.
     header("Location: {$this->controllerUrl}");
 }
开发者ID:ricain59,项目名称:fortaff,代码行数:21,代码来源:authHelper.php

示例8: cw_googleplus_on_logout

function cw_googleplus_on_logout()
{
    $googleplus_login_info =& cw_session_register('googleplus_login_info');
    unset($googleplus_login_info['token']);
    $google_client_id = '376787991969-2c127o3n2vollhqfla26q1mfu1qi7n8s.apps.googleusercontent.com';
    $google_client_secret = '25mdbO_DAlPE_aST_hErSzDN';
    $google_redirect_url = 'http://dev.cartworks.com/product_stages/index.php';
    //path to your script
    $google_developer_key = 'AIzaSyAOCvjaVfFFiL4OnlI8du8pHHNZGPsY3iU';
    cw_include('addons/googleplus_login/include/src/Google_Client.php');
    cw_include('addons/googleplus_login/include/src/contrib/Google_Oauth2Service.php');
    $gClient = new Google_Client();
    $gClient->setApplicationName('Test Google+ Login CW');
    $gClient->setClientId($google_client_id);
    $gClient->setClientSecret($google_client_secret);
    $gClient->setRedirectUri($google_redirect_url);
    $gClient->setDeveloperKey($google_developer_key);
    $gClient->revokeToken();
}
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:19,代码来源:func.php

示例9: RevokeAccess

 /**
  * Function to revoke the application access to google account. Dumn revoke process - revokes all your account access.
  * @param array ['user_id'=> user id, 'media_id'=> social media id]
  * @return boolean true|false
  * @throws \Google_Exception if user id or media id are missed
  */
 public function RevokeAccess($params)
 {
     $USER_ID = isset($params[self::USER_ID]) ? $params[self::USER_ID] : null;
     $GOOGLE_MEDIA_ID = isset($params[self::MEDIA_ID]) ? $params[self::MEDIA_ID] : null;
     if (!isset($USER_ID) || !isset($GOOGLE_MEDIA_ID)) {
         throw new \Google_Exception('User ID and / or Google Media ID are invalid');
     }
     $oMediaUserMapper = new \Av\MediaUserModel();
     $params_user_credentials = array(\Av\MediaUserModel::MEDIA_ID => $GOOGLE_MEDIA_ID, \Av\MediaUserModel::USER_ID => $USER_ID);
     $arrUserCredentials = $oMediaUserMapper->GetCredentials($params_user_credentials);
     if (empty($arrUserCredentials[\Av\MediaUserModel::REFRESH_TOKEN])) {
         throw new \Google_Exception("Refresh token is not set for user id {$USER_ID} media id {$GOOGLE_MEDIA_ID} ");
     }
     if (empty($arrUserCredentials[\Av\MediaUserModel::ACCESS_TOKEN])) {
         throw new \Google_Exception("Access token is not set for user id {$USER_ID} media id {$GOOGLE_MEDIA_ID} ");
     }
     // 3. Extract access token
     //        $ACCESS_TOKEN		=   $arrUserCredentials[\Av\MediaUserModel::ACCESS_TOKEN];
     $REFRESH_TOKEN = $arrUserCredentials[\Av\MediaUserModel::REFRESH_TOKEN];
     $client = new \Google_Client();
     return $client->revokeToken($REFRESH_TOKEN);
 }
开发者ID:avassilenko,项目名称:av_2,代码行数:28,代码来源:GoogleDeauthorizeController.php

示例10: authenticate

 public function authenticate($sl)
 {
     $response = null;
     $config = $sl->get('config');
     $googleApi = $config['google-api'];
     $gClient = new \Google_Client();
     $gClient->setApplicationName('ginosi');
     $gClient->setClientId($googleApi['clientId']);
     $gClient->setClientSecret($googleApi['clientSecret']);
     $gClient->setRedirectUri($googleApi['redirectUri']);
     $gClient->setDeveloperKey($googleApi['developerKey']);
     $gClient->setScopes($googleApi['scopes']);
     $google_oauthV2 = new \Google_Service_Oauth2($gClient);
     if (isset($_REQUEST['reset'])) {
         unset($_SESSION['token']);
         $gClient->revokeToken();
         header('Location: ' . filter_var($google_redirect_url, FILTER_SANITIZE_URL));
     }
     if (isset($_GET['code'])) {
         $session = new Container('accesstoken');
         $gClient->authenticate($_GET['code']);
         $accessToken = $gClient->getAccessToken();
         $data = \Zend\Json\Json::decode($accessToken, \Zend\Json\Json::TYPE_ARRAY);
         $session->token = $data['access_token'];
     }
     if (isset($accessToken)) {
         $gClient->setAccessToken($gClient->getAccessToken());
     }
     if ($gClient->getAccessToken()) {
         $user = $google_oauthV2->userinfo->get();
         $email = filter_var($user['email'], FILTER_SANITIZE_EMAIL);
         $result = ['verified', $email];
         return $result;
     } else {
         return $gClient->createAuthUrl();
     }
 }
开发者ID:arbi,项目名称:MyCode,代码行数:37,代码来源:GoogleAuth.php

示例11: gmail

 function gmail()
 {
     $google_client_id = '268142142707-blppmfbga75qrdlv2r706k4tae91oo4h.apps.googleusercontent.com';
     $google_client_secret = '0RXg84sxNKSPOfriAfXvMZcG';
     $google_redirect_url = 'http://www.stylior.com/home/gmail/';
     //path to your script
     $google_developer_key = '';
     //include google api files
     require_once 'site/views/src/Google_Client.php';
     require_once 'site/views/src/contrib/Google_Oauth2Service.php';
     $this->load->library('session');
     $gClient = new Google_Client();
     $gClient->setApplicationName('Login to stylior.com');
     $gClient->setClientId($google_client_id);
     $gClient->setClientSecret($google_client_secret);
     $gClient->setRedirectUri($google_redirect_url);
     $gClient->setDeveloperKey($google_developer_key);
     $google_oauthV2 = new Google_Oauth2Service($gClient);
     //If user wish to log out, we just unset Session variable
     if (isset($_REQUEST['reset'])) {
         unset($_SESSION['token']);
         $gClient->revokeToken();
         header('Location: ' . filter_var($google_redirect_url, FILTER_SANITIZE_URL));
         //redirect user back to page
     }
     if (isset($_REQUEST['code'])) {
         $gClient->authenticate($_REQUEST['code']);
         $_SESSION['token'] = $gClient->getAccessToken();
     }
     if (isset($_SESSION['token'])) {
         $gClient->setAccessToken($_SESSION['token']);
     }
     if ($gClient->getAccessToken()) {
         //For logged in user, get details from google using access token
         $user = $google_oauthV2->userinfo->get();
         $user_id = $user['id'];
         $user_name = filter_var($user['name'], FILTER_SANITIZE_SPECIAL_CHARS);
         $email = filter_var($user['email'], FILTER_SANITIZE_EMAIL);
         $profile_url = filter_var($user['link'], FILTER_VALIDATE_URL);
         $profile_image_url = filter_var($user['picture'], FILTER_VALIDATE_URL);
         $personMarkup = "{$email}<div><img src='{$profile_image_url}?sz=50'></div>";
         $_SESSION['token'] = $gClient->getAccessToken();
     } else {
         //For Guest user, get google login url
         $authUrl = $gClient->createAuthUrl();
     }
     if (isset($authUrl)) {
         //echo '<a class="login" href="'.$authUrl.'"><img src="images/google-login-button.png" /></a>';
     } else {
         // print_r($email);die;
         $userdata = $this->user_model->facebooklogin($email);
         if ($userdata != '') {
             $newuserdata = array('username' => $userdata->username, 'userid' => $userdata->id, 'email' => $userdata->email, 'insider' => $userdata->insider, 'logged_in' => true);
             $check = $this->session->set_userdata($newuserdata);
             $_SESSION['username'] = $userdata->username;
             $_SESSION['userid'] = $userdata->id;
             $_SESSION['email'] = $userdata->email;
             $_SESSION['insider'] = $userdata->insider;
             $_SESSION['logged_in'] = true;
             $customize = $this->session->userdata('customize');
             /* code added by MSYS009 */
             $cartdata = $this->user_model->cartdata($_SESSION['userid']);
             if ($cartdata != '' && count($cartdata) > 0) {
                 foreach ($cartdata as $cd) {
                     $optionarr = json_decode($cd->options);
                     foreach ($optionarr as $key => $value) {
                         $optionarr1[$key] = $value;
                     }
                     $data['cartprod'] = array('id' => $cd->pid, 'qty' => $cd->qty, 'price' => $cd->price, 'name' => $cd->pname, 'options' => $optionarr1);
                     $this->cart->insert($data['cartprod']);
                 }
             }
             // redirecting to add cart functio based on 3d data selection  -- MSYS009
             if (isset($_SESSION['selected3dInfo']) && !empty($_SESSION['selected3dInfo'])) {
                 // echo "hihi".$this->config->item('base_url');exit;
                 redirect($this->config->item('base_url') . 'cart/addcart3d', 'location');
             }
             // redirecting to save cart function based on 3d data selection  -- MSYS009
             if (isset($_SESSION['save3dInfo']) && !empty($_SESSION['save3dInfo'])) {
                 //echo "hihi".$this->config->item('base_url');exit;
                 redirect($this->config->item('base_url') . 'cart/save3d/', 'location');
             }
             /* code added by MSYS009(END) */
             if ($customize != '' && $_SESSION['cust_fab_id'] == '') {
                 redirect($this->config->item('http_host') . '/3dshirt?id=' . $customize, 'location');
             }
             if ($_SESSION['customize'] == '1' && $_SESSION['cust_fab_id'] != '') {
                 redirect($this->config->item('http_host') . '3dshirt/index.php?fab_id=' . $_SESSION['cust_fab_id'], 'location');
             }
             if ($_SESSION['customize'] == '1') {
                 redirect($this->config->item('http_host') . '/3dshirt', 'location');
             }
             if ($this->session->userdata('cstyleid') != '' && $this->session->userdata('prodid') != '') {
                 redirect($this->config->item('base_url') . 'home/measurement/' . $this->session->userdata('cstyleid') . '/' . $this->session->userdata('prodid') . '', 'location');
             } else {
                 redirect($this->config->item('base_url') . '', 'location');
             }
         } else {
             $content['email'] = $email;
             $content['name'] = $user_name;
//.........这里部分代码省略.........
开发者ID:ksakinala-c,项目名称:Styler,代码行数:101,代码来源:home.php

示例12: unset

if (!file_exists($page_to_load . ".file")) {
    $page_to_load = "404";
}
$_SESSION["page_to_load"] = $page_to_load;
$gClient = new Google_Client();
$gClient->setApplicationName('TLV TimeBank');
//Login to Sanwebe.com
$gClient->setClientId($google_client_id);
$gClient->setClientSecret($google_client_secret);
$gClient->setRedirectUri($google_redirect_url);
$gClient->setDeveloperKey($google_developer_key);
$google_oauthV2 = new Google_Oauth2Service($gClient);
//If user wish to log out, we just unset Session variable
if (isset($_REQUEST['reset'])) {
    unset($_SESSION['token']);
    $gClient->revokeToken();
    header('Location: ' . filter_var($google_redirect_url, FILTER_SANITIZE_URL));
    //redirect user back to page
}
//If code is empty, redirect user to google authentication page for code.
//Code is required to aquire Access Token from google
//Once we have access token, assign token to session variable
//and we can redirect user back to page and login.
if (isset($_GET['code'])) {
    $gClient->authenticate($_GET['code']);
    $_SESSION['token'] = $gClient->getAccessToken();
    header('Location: ' . filter_var($google_redirect_url, FILTER_SANITIZE_URL));
    return;
}
if (isset($_SESSION['token'])) {
    $gClient->setAccessToken($_SESSION['token']);
开发者ID:aryehbeitz,项目名称:tlvtimebank,代码行数:31,代码来源:index.php

示例13: unset

 function K_google()
 {
     $ci =& get_instance();
     $ci->load->config('google');
     $google_client_id = $ci->config->item('google_client_id');
     $google_client_secret = $ci->config->item('google_client_secret');
     $google_redirect_url = $ci->config->item('google_redirect_url');
     //path to your script
     $google_developer_key = $ci->config->item('google_developer_key');
     require_once 'src/Google_Client.php';
     require_once 'src/contrib/Google_Oauth2Service.php';
     $gClient = new Google_Client();
     $gClient->setClientId($google_client_id);
     $gClient->setClientSecret($google_client_secret);
     $gClient->setRedirectUri($google_redirect_url);
     $gClient->setDeveloperKey($google_developer_key);
     $google_oauthV2 = new Google_Oauth2Service($gClient);
     //If user wish to log out, we just unset Session variable
     if (isset($_REQUEST['reset'])) {
         unset($_SESSION['token']);
         $gClient->revokeToken();
         header('Location: ' . filter_var($google_redirect_url, FILTER_SANITIZE_URL));
         //redirect user back to page
     }
     if (!isset($_GET['code']) && empty($_REQUEST['state'])) {
         unset($_SESSION['token']);
     }
     //If code is empty, redirect user to google authentication page for code.
     //Code is required to aquire Access Token from google
     //Once we have access token, assign token to session variable
     //and we can redirect user back to page and login.
     if (isset($_GET['code']) && empty($_REQUEST['state'])) {
         $gClient->authenticate($_GET['code']);
         $_SESSION['token'] = $gClient->getAccessToken();
         //echo $_SESSION['token'];die;
         //header('Location: ' . filter_var($google_redirect_url, FILTER_SANITIZE_URL));
         //return;
     }
     if (isset($_SESSION['token'])) {
         //echo "tokent->".$_SESSION['token'];
         $gClient->setAccessToken($_SESSION['token']);
     }
     //echo "aceec->". $gClient->getAccessToken(); die;
     if ($gClient->getAccessToken()) {
         //For logged in user, get details from google using access token
         $data['guser'] = $google_oauthV2->userinfo->get();
         $data['guser_id'] = $data['guser']['id'];
         $data['guser_name'] = filter_var($data['guser']['name'], FILTER_SANITIZE_SPECIAL_CHARS);
         $data['gemail'] = filter_var($data['guser']['email'], FILTER_SANITIZE_EMAIL);
         //$data['gprofile_url'] = filter_var($data['guser']['link'], FILTER_VALIDATE_URL);
         $data['gprofile_image_url'] = filter_var($data['guser']['picture'], FILTER_VALIDATE_URL);
         $gprofile_image_url = $data['gprofile_image_url'];
         $email = $data['gemail'];
         $data['gpersonMarkup'] = "{$email}<div><img src='{$gprofile_image_url}?sz=50'></div>";
         $user = $data['guser'];
         //            echo "<pre>";
         //            print_r($user);
         //            exit;
         //exit;
         if (!empty($user)) {
             $get_users = $ci->user_model->get_user_by_filed('primary_email', $user['email']);
             $chek_email_id_exist = $ci->user_model->check_duplicate_email_by_filed('primary_email', $user['email']);
             if (count($get_users) == 0 && $chek_email_id_exist == True) {
                 $random_string = generate_password();
                 $username = $user['given_name'] . $random_string;
                 $user_rand_id = get_user_rand_id();
                 $data_to_store = array('user_rand_id' => $user_rand_id, 'firstname' => $user['given_name'], 'google_id' => $user['id'], 'username' => $username, 'lastname' => $user['family_name'], 'primary_email' => $user['email'], 'avatar' => $user['picture'], 'type_of_membership' => 'FREE', 'date_of_registration' => date("Y-m-d H:i:s"), 'last_login' => date("Y-m-d H:i:s"), 'status' => 'Active');
                 $ci->user_model->store_user($data_to_store);
                 $last_id = $ci->db->insert_id();
                 $get_member = 'FREE';
                 $session = array('username' => $username, 'user_id' => $last_id, 'type_of_membership' => $get_member, 'login_google' => 1, 'is_logged_in' => true);
                 $ci->session->set_userdata($session);
                 if (isset($_GET['code'])) {
                     echo "<script>\n        window.close();\n        window.opener.location.reload();\n                                </script>";
                 }
             } else {
                 $username_details = $ci->user_model->get_username_by_email_id($user['email']);
                 if (!empty($username_details)) {
                     $username1 = $username_details[0]['username'];
                 }
                 $data_to_store = array('firstname' => $user['given_name'], 'google_id' => $user['id'], 'lastname' => $user['family_name'], 'gender' => $user['gender'], 'avatar' => $user['picture'], 'last_login' => date("Y-m-d H:i:s"));
                 $ci->user_model->update_user_by_field('primary_email', $get_users[0]['primary_email'], $data_to_store);
                 $last_id1 = $get_users[0]['user_id'];
                 $get_member = 'FREE';
                 $session = array('username' => $username1, 'user_id' => $last_id1, 'type_of_membership' => $get_member, 'login_google' => 1, 'is_logged_in' => true);
                 $ci->session->set_userdata($session);
                 if (isset($_GET['code'])) {
                     echo "<script>\n        window.close();\n        window.opener.location.reload();\n                                </script>";
                 }
             }
         }
     } else {
         $data['authUrl'] = $gClient->createAuthUrl();
     }
     return $data;
 }
开发者ID:bhushansonar,项目名称:knewdog.com,代码行数:96,代码来源:common_helper.php

示例14: checkVotingRights

        $_SESSION['canVote'] = checkVotingRights($_SESSION["token_data"]["payload"]["email"]);
        $oAuth2 = new \Google_Service_Oauth2($client);
        $oAttr = $oAuth2->userinfo->get();
    } catch (Exception $e) {
        unset($_SESSION['access_token']);
        $redirect_uri = $_SERVER["REQUEST_SCHEME"] . '://' . $_SERVER['HTTP_HOST'];
        header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
    }
}
if (isset($_GET['logout'])) {
    // Need to proxy if needed.
    if (function_exists('setProxy')) {
        setProxy();
        $client->getIo()->setOptions(array(CURLOPT_PROXY => 'localhost', CURLOPT_PROXYPORT => 8888));
    }
    $client->revokeToken($_SESSION['access_token']);
    unset($_SESSION['access_token']);
    $_SESSION = array();
    $redirect_uri = $_SERVER["REQUEST_SCHEME"] . '://' . $_SERVER['HTTP_HOST'];
    header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
    die;
}
/** Send the user for authentication with Google
 * will call us again with ?code set.*/
if (isset($_GET['login'])) {
    $client->setRedirectUri($_SERVER["REQUEST_SCHEME"] . '://' . $_SERVER['HTTP_HOST']);
    $client->addScope("https://www.googleapis.com/auth/userinfo.profile");
    $client->addScope("https://www.googleapis.com/auth/userinfo.email");
    // Need to proxy if needed.
    if (function_exists('setProxy')) {
        $client->getIo()->setOptions(array(CURLOPT_PROXY => 'localhost', CURLOPT_PROXYPORT => 8888));
开发者ID:rexsuecia,项目名称:nameit,代码行数:31,代码来源:name.php

示例15: clearToken

 /**
  * Clear auth token
  */
 public function clearToken()
 {
     $this->googleApiClient->revokeToken();
 }
开发者ID:martin1982,项目名称:live-broadcast-bundle,代码行数:7,代码来源:YouTubeApiService.php


注:本文中的Google_Client::revokeToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。