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


PHP Google_Client::addScope方法代码示例

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


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

示例1: getClient

 public static function getClient()
 {
     $creds = GoogleSessionController::getCreds();
     $client = new Google_Client();
     $env = Config::getEnvironment();
     if ($env == 'local' && $creds->oauth_local_path) {
         $client->setAuthConfigFile($creds->oauth_local_path);
     } else {
         if ($creds->oauth_remote_path) {
             $client->setAuthConfigFile($creds->oauth_remote_path);
         } else {
             $client->setApplicationName($creds->app_name);
             $client->setClientId($creds->client_id);
             $client->setClientSecret($creds->client_secret);
         }
     }
     $client->setRedirectUri(GoogleSessionController::getRedirectURI());
     $hd = Config::get('config.google.hd');
     if ($hd) {
         $client->setHostedDomain($hd);
     }
     $client->setAccessType('offline');
     $client->addScope("https://www.googleapis.com/auth/userinfo.profile");
     $client->addScope("https://www.googleapis.com/auth/userinfo.email");
     $client->setScopes($creds->scopes);
     return $client;
 }
开发者ID:vanderlin,项目名称:halp,代码行数:27,代码来源:GoogleSessionController.php

示例2: flow

 /**
  * Google login method
  * --
  */
 public function flow()
 {
     $client = new Google_Client();
     $client->setClientId($this->client_id);
     $client->setClientSecret($this->client_secret);
     $client->setRedirectUri($this->redirect_url);
     $client->addScope("email");
     $client->addScope("profile");
     $this->context = Context::getContext();
     $this->client = $client;
     $this->service = new Google_Service_Oauth2($this->client);
     if (Tools::getValue('code')) {
         $this->client->authenticate(Tools::getValue('code'));
         $this->context->cookie->__set('googleconnect_access_token', serialize($this->client->getAccessToken()));
         Tools::redirect(filter_var($this->redirect_url, FILTER_SANITIZE_URL));
     } else {
         if ($this->context->cookie->__isset('googleconnect_access_token')) {
             $a_token = unserialize($this->context->cookie->__get('googleconnect_access_token'));
             $this->client->setAccessToken($a_token);
             if (!$this->client->isAccessTokenExpired()) {
                 $this->context->cookie->__unset('googleconnect_access_token');
                 $this->loginToStore();
             } else {
                 $this->setAuthUrl();
             }
         } else {
             $this->setAuthUrl();
         }
     }
 }
开发者ID:garyconstable,项目名称:prestashop-google-connect,代码行数:34,代码来源:login.php

示例3: index

 public function index()
 {
     //Config items added to global config file
     $clientId = $this->config->item('clientId');
     $clientSecret = $this->config->item('clientSecret');
     $redirectUrl = $this->config->item('redirectUrl');
     #session_start();
     $client = new Google_Client();
     $client->setClientId($clientId);
     $client->setClientSecret($clientSecret);
     $client->setRedirectUri($redirectUrl);
     #$client->setScopes(array('https://spreadsheets.google.com/feeds'));
     $client->addScope(array('https://spreadsheets.google.com/feeds'));
     $client->addScope('email');
     $client->addScope('profile');
     $client->setApprovalPrompt('force');
     //Useful if you had already granted access to this application.
     $client->setAccessType('offline');
     //Needed to get a refresh_token
     $data['base_url'] = $this->config->item('base_url');
     $data['auth_url'] = $client->createAuthUrl();
     //Set canonical URL
     $data['canonical'] = $this->config->item('base_url') . 'docs';
     $this->load->view('docs', $data);
 }
开发者ID:SaintGrey,项目名称:sheets2,代码行数:25,代码来源:docs.php

示例4: call_back

 public function call_back()
 {
     $config = new Controllers_Api_Google_Config_App();
     $client = new Google_Client();
     $client->setClientId($config->config['client_id']);
     $client->setClientSecret($config->config['client_secret']);
     $client->setRedirectUri($config->config['redirect_uri']);
     $client->addScope("email");
     $client->addScope("profile");
     $service = new Google_Service_Oauth2($client);
     if (isset($_GET['code'])) {
         $client->authenticate($_GET['code']);
         $_SESSION['access_token'] = $client->getAccessToken();
         header('Location: ' . filter_var($config->config['redirect_uri'], FILTER_SANITIZE_URL));
         exit;
     }
     /************************************************
         If we have an access token, we can make
         requests, else we generate an authentication URL.
        ************************************************/
     if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
         $client->setAccessToken($_SESSION['access_token']);
     } else {
         $authUrl = $client->createAuthUrl();
     }
     if (isset($authUrl)) {
         //show login url
         echo json_encode(array('status' => false, 'data' => $authUrl));
     } else {
         $user = $service->userinfo->get();
         //get user info
         echo json_encode(array('status' => true, 'data' => $user));
     }
 }
开发者ID:anovanmaximuz,项目名称:sosmed-cms,代码行数:34,代码来源:post.php

示例5: authorizeGoogleUser

 function authorizeGoogleUser($access_code)
 {
     $client = new \Google_Client();
     $google = $this->config->google;
     $client->setApplicationName('Portal da Rede');
     $client->setClientId($google->clientId);
     $client->setClientSecret($google->secret);
     $client->setRedirectUri('postmessage');
     $client->addScope('https://www.googleapis.com/auth/userinfo.profile');
     $client->addScope('https://www.googleapis.com/auth/userinfo.email');
     $client->authenticate($access_code);
     $json_token = $client->getAccessToken();
     $client->setAccessToken($json_token);
     $plus = new \Google_Service_Plus($client);
     $user = $plus->people->get('me');
     if (!$user->emails || !is_array($user->emails)) {
         return;
     }
     $email = $user->emails[0]['value'];
     $user_email = $this->db->user_email->find_one($email);
     if (!$user_email) {
         return;
     }
     $this->login($user_email->user);
 }
开发者ID:kahvazquez,项目名称:trouble,代码行数:25,代码来源:User.php

示例6: __construct

 public function __construct(\Google_Client $googleClient, $clientSecretPath)
 {
     $this->_googleClient = $googleClient;
     $this->_googleClient->setAuthConfigFile($clientSecretPath);
     $this->_googleClient->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/loginGoogle');
     $this->_googleClient->addScope(\Google_Service_Gmail::GMAIL_READONLY);
     $this->_gmailService = new \Google_Service_Gmail($this->_googleClient);
 }
开发者ID:nissnac,项目名称:GettingStarted-Cloud,代码行数:8,代码来源:GoogleServices.php

示例7: load_google_analytics

 private function load_google_analytics()
 {
     WooCommerce_Grow::load_google_analytics();
     // We setup the Google Client object
     $this->client = new Google_Client();
     $this->client->setAuthConfigFile(WooCommerce_Grow::get_plugin_path() . '\\ga-config.json');
     $this->client->addScope(Google_Service_Analytics::ANALYTICS_READONLY);
     $this->analytics = new Google_Service_Analytics($this->client);
 }
开发者ID:raisonon,项目名称:woocommerce-grow,代码行数:9,代码来源:class-woocommerce-grow-google-analytics.php

示例8: __construct

 /**
  * GoogleServiceProvider constructor.
  * @param $config
  */
 public function __construct()
 {
     $this->client = new \Google_Client();
     $this->projectName = config('google_cloud_storage.application');
     $this->projectBucket = config('google_cloud_storage.bucket');
     $this->authJsonFile = config('google_cloud_storage.auth_json_filename');
     $this->client->setApplicationName($this->projectName);
     $this->client->setAuthConfigFile(base_path($this->authJsonFile));
     $this->client->addScope(\Google_Service_Storage::DEVSTORAGE_FULL_CONTROL);
 }
开发者ID:io-digital,项目名称:google-cloud-storage,代码行数:14,代码来源:GoogleClient.php

示例9: __construct

 /**
  * GoogleServiceProvider constructor.
  * @param $config
  */
 public function __construct()
 {
     $this->client = new \Google_Client();
     $this->projectName = config('google_pub_sub.application');
     $this->authJsonFile = config('google_pub_sub.auth_json_filename');
     $this->client->setApplicationName($this->projectName);
     $this->client->setAuthConfigFile(base_path($this->authJsonFile));
     //THIS IS NEEDED FOR CHROME ENV
     //$this->client->useApplicationDefaultCredentials();
     $this->client->addScope(Google_Service_Pubsub::PUBSUB);
 }
开发者ID:io-digital,项目名称:google-pub-sub,代码行数:15,代码来源:GoogleClient.php

示例10: initializeClient

 public function initializeClient()
 {
     $this->client = new Client();
     $this->client->setAccessType('offline');
     $this->client->setApplicationName('playlister');
     $this->client->setClientId($this->config->get('services.youtube.client_id'));
     $this->client->setClientSecret($this->config->get('services.youtube.client_secret'));
     $this->client->setRedirectUri($this->config->get('services.youtube.redirect'));
     $this->client->setDeveloperKey($this->config->get('services.youtube.api_key'));
     $this->client->addScope('https://www.googleapis.com/auth/youtube.readonly');
     if ($this->auth->check() && $this->request->session()->has('user.token')) {
         $this->setToken($this->request->session()->get('user.token'));
     }
 }
开发者ID:JoeAlamo,项目名称:Playlister,代码行数:14,代码来源:YoutubeAPIService.php

示例11: googleConnect

function googleConnect()
{
    require_once 'lib/Google/autoload.php';
    /* * *********************Google login************************ */
    $client = new Google_Client();
    $client->setClientId(CLIENT_ID);
    $client->setClientSecret(CLIENT_SECRET);
    $client->setRedirectUri(GOOGLE_REDIRECT_URI);
    $client->setAccessType('offline');
    $client->setApprovalPrompt('force');
    $client->addScope("openid email");
    $client->addScope("https://picasaweb.google.com/data/");
    $client->addScope("https://www.googleapis.com/auth/userinfo.profile");
    return $client;
}
开发者ID:shalinis34,项目名称:Facebook-Albums,代码行数:15,代码来源:function.php

示例12: 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

示例13: getClient

 public static function getClient()
 {
     // $config = self::loadConfig();
     $client = new Google_Client();
     $client->setAuthConfigFile(dirname(__FILE__) . '/client_secret.json');
     $client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . FOLDER_APP);
     $client->addScope(Google_Service_Gmail::MAIL_GOOGLE_COM);
     $client->addScope(Google_Service_Gmail::GMAIL_COMPOSE);
     $client->addScope(Google_Service_Gmail::GMAIL_MODIFY);
     $client->addScope('http://www.google.com/m8/feeds/');
     $client->addScope('https://www.googleapis.com/auth/userinfo.email');
     $client->setIncludeGrantedScopes(true);
     $client->setAccessType('offline');
     $client->setApprovalPrompt('force');
     return $client;
 }
开发者ID:able-to-include,项目名称:email-client,代码行数:16,代码来源:GoogleHelper.php

示例14: init

 /**
  * Initializes the Google Drive connection
  *
  * @param   array   $params  Any connection params needed
  * @return  object
  **/
 public static function init($params = [])
 {
     // Get the params
     $pparams = Plugin::params('filesystem', 'googledrive');
     $app_id = isset($params['app_id']) && $params['app_id'] != '' ? $params['app_id'] : $pparams->get('app_id');
     $app_secret = isset($params['app_secret']) && $params['app_secret'] != '' ? $params['app_secret'] : $pparams->get('app_secret');
     $client = new \Google_Client();
     $client->setClientId($app_id);
     $client->setClientSecret($app_secret);
     $client->addScope(Google_Service_Drive::DRIVE);
     $client->setAccessType('offline');
     $client->setApprovalPrompt('force');
     $client->setIncludeGrantedScopes(true);
     if (isset($params['app_token'])) {
         $accessToken = $params['app_token'];
         // json encode turned our array into an object, we need to undo that
         $accessToken = (array) $accessToken;
     } else {
         \Session::set('googledrive.app_id', $app_id);
         \Session::set('googledrive.app_secret', $app_secret);
         \Session::set('googledrive.connection_to_set_up', Request::getVar('connection', 0));
         // Set upp a return and redirect to Google for auth
         $return = Request::getVar('return') ? Request::getVar('return') : Request::current(true);
         $return = base64_encode($return);
         $redirectUri = trim(Request::root(), '/') . '/developer/callback/googledriveAuthorize';
         $client->setRedirectUri($redirectUri);
         Session::set('googledrive.state', $return);
         App::redirect($client->createAuthUrl());
     }
     $client->setAccessToken($accessToken);
     $service = new \Google_Service_Drive($client);
     $adapter = new \Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter($service, 'root');
     return $adapter;
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:40,代码来源:googledrive.php

示例15: googlecallback

 public function googlecallback()
 {
     $ret = null;
     //$google_redirect_url = site_url('user/signup');
     $google_redirect_url = 'http://localhost/punu/punu/index.php/user/signup';
     $client = new Google_Client();
     $client->setClientId($this->google_client_id);
     $client->setClientSecret($this->google_client_secret);
     $client->setDeveloperKey($this->google_api_key);
     $client->setRedirectUri($google_redirect_url);
     $client->addScope($this->google_scope);
     // Send Client Request
     $objOAuthService = new Google_Service_Oauth2($client);
     // Add Access Token to Session
     if (isset($_GET['code'])) {
         $client->authenticate($_GET['code']);
         $_SESSION['google_access_token'] = $client->getAccessToken();
         //header('Location: ' . filter_var($this->google_redirect_url, FILTER_SANITIZE_URL));
     }
     // Set Access Token to make Request
     if (isset($_SESSION['google_access_token']) && $_SESSION['google_access_token']) {
         $client->setAccessToken($_SESSION['google_access_token']);
     }
     // Get User Data from Google and store them in $data
     if ($client->getAccessToken()) {
         $userData = $objOAuthService->userinfo->get();
         //$_SESSION['userData'] = $userData;
         $_SESSION['google_access_token'] = $client->getAccessToken();
         $ret = $userData;
     }
     return $ret;
 }
开发者ID:arunmisra2273,项目名称:punu,代码行数:32,代码来源:Plalib.php


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