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


PHP Google_Client::setAuthConfigFile方法代码示例

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


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

示例1: getGoogleApiClient

 /**
  * Returns an authorized API client.
  * @return Google_Client the authorized client object
  */
 private function getGoogleApiClient()
 {
     $client = new Google_Client();
     $client->setApplicationName($this->CFG['GOOGLE_API_APPLICATION_NAME']);
     $client->setScopes(Google_Service_Calendar::CALENDAR);
     $client->setAuthConfigFile($this->CFG['GOOGLE_API_CLIENT_SECRET_PATH']);
     $client->setAccessType('offline');
     // Load previously authorized credentials from a file.
     $credentialsPath = $this->CFG['GOOGLE_API_CREDENTIALS_PATH'];
     if (file_exists($credentialsPath)) {
         $accessToken = file_get_contents($credentialsPath);
     } else {
         // Request authorization from the user.
         $authUrl = $client->createAuthUrl();
         printf("Open the following link in your browser:\n%s\n", $authUrl);
         print 'Enter verification code: ';
         $authCode = trim(fgets(STDIN));
         // Exchange authorization code for an access token.
         $accessToken = $client->authenticate($authCode);
         // Store the credentials to disk.
         if (!file_exists(dirname($credentialsPath))) {
             mkdir(dirname($credentialsPath), 0700, true);
         }
         file_put_contents($credentialsPath, $accessToken);
         printf("Credentials saved to %s\n", $credentialsPath);
     }
     $client->setAccessToken($accessToken);
     // Refresh the token if it's expired.
     if ($client->isAccessTokenExpired()) {
         $client->refreshToken($client->getRefreshToken());
         file_put_contents($credentialsPath, $client->getAccessToken());
     }
     return $client;
 }
开发者ID:neocodesoftware,项目名称:NeoCode-FmUsage,代码行数:38,代码来源:class.GoogleApi.php

示例2: getGoogleClient

 private static function getGoogleClient($config)
 {
     $client = new \Google_Client();
     $config = self::getGoogleConfig($config);
     $client->setAuthConfigFile($config);
     $userId = \HttpReceiver\HttpReceiver::get('userId', 'int');
     if (!isset($userId)) {
         $userId = \HttpReceiver\HttpReceiver::get('state', 'int');
     }
     $client->setRedirectUri($config['GOOGLEDRIVE_REDIRECT2']);
     $client->addScope(\Google_Service_Drive::DRIVE);
     return $client;
 }
开发者ID:Nickstery,项目名称:CloudUploader-SDK,代码行数:13,代码来源:GoogleDriveModel.php

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

示例4: __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

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

示例6: __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

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

示例8: initializeObject

 /**
  * Initialize the google calendar
  *
  * @throws \KevinDitscheid\KdCalendar\Exception\NoAuthDataException
  */
 public function initializeObject()
 {
     $this->settings = \KevinDitscheid\KdCalendar\Utility\ExtensionUtility::getMergedExtensionConfiguration();
     $this->client = new \Google_Client();
     $this->client->setApplicationName($this->settings['applicationName']);
     $this->client->setScopes(\Google_Service_Calendar::CALENDAR_READONLY);
     if ($this->settings['auth']['jsonFile']) {
         $this->client->setAuthConfigFile($this->settings['auth']['jsonFile']);
     } elseif ($this->settings['auth']['jsonString']) {
         $this->client->setAuthConfig($this->settings['auth']['jsonString']);
     } else {
         throw new \KevinDitscheid\KdCalendar\Exception\NoAuthDataException("No auth data is provided for Google Calendar!", 1454958940);
     }
     $this->client->setAccessType(self::ACCESS_TYPE_OFFLINE);
 }
开发者ID:bara0801,项目名称:kd_calendar,代码行数:20,代码来源:GoogleCalendarService.php

示例9: getClient

function getClient()
{
    $client = new Google_Client();
    $client->setApplicationName(APPLICATION_NAME);
    $client->setScopes(SCOPES);
    $client->setAuthConfigFile(CLIENT_SECRET);
    $client->setAccessType('offline');
    // Load previously authorized credentials from a file.
    $credentialsPath = expandHomeDirectory(CREDENTIAL_PATH);
    if (file_exists($credentialsPath)) {
        $accessToken = file_get_contents($credentialsPath);
    } else {
        // Request authorization from the user.
        $authUrl = $client->createAuthUrl();
        printf("Open the following link in your browser:\n\n\t%s\n\n", $authUrl);
        print 'Enter verification code: ';
        $authCode = trim(fgets(STDIN));
        // Exchange authorization code for an access token.
        $accessToken = $client->authenticate($authCode);
        // Store the credentials to disk.
        if (!file_exists(dirname($credentialsPath))) {
            mkdir(dirname($credentialsPath), 0700, true);
        }
        file_put_contents($credentialsPath, $accessToken);
        printf("Credentials saved to %s\n", $credentialsPath);
    }
    $client->setAccessToken($accessToken);
    // Refresh the token if it's expired.
    if ($client->isAccessTokenExpired()) {
        $client->refreshToken($client->getRefreshToken());
        file_put_contents($credentialsPath, $client->getAccessToken());
    }
    return $client;
}
开发者ID:cmunky,项目名称:gcontact,代码行数:34,代码来源:gascapi.php

示例10: getClient

/**
 * Returns an authorized API client.
 * @return Google_Client the authorized client object
 */
function getClient()
{
    $client = new Google_Client();
    $client->setApplicationName("Study Group Finder");
    $client->setAuthConfigFile(__DIR__ . '/client_secret.json');
    $client->addScope(Google_Service_Calendar::CALENDAR);
    $client->setRedirectUri(current_url());
    if (isset($_SESSION["googleauth"])) {
        $client->setAccessToken($_SESSION["googleauth"]);
        $_SESSION["googleauth"] = NULL;
        return $client;
    }
    if (!isset($_GET['code'])) {
        // Request authorization from the user.
        $authUrl = $client->createAuthUrl();
        header("Location: {$authUrl}");
        exit(0);
    }
    $authCode = $_GET['code'];
    // Exchange authorization code for an access token.
    $accessToken = $client->authenticate($authCode);
    $_SESSION["googleauth"] = $accessToken;
    header("Location: calendar.php");
    exit(0);
}
开发者ID:magical,项目名称:cs290-project,代码行数:29,代码来源:calendar.php

示例11: getClient

/**
 * Returns an authorized API client.
 * @return Google_Client the authorized client object
 */
function getClient()
{
    global $credentialsPath;
    $client = new Google_Client();
    $client->setApplicationName(APPLICATION_NAME);
    $client->setScopes(GAPI_SCOPES);
    $client->setAuthConfigFile(CLIENT_SECRET_PATH);
    $client->setAccessType('offline');


    if (file_exists($credentialsPath)) {
        $accessToken = file_get_contents($credentialsPath);
    } else {
        die("Please, get token via connect.php");
    }

    $client->setAccessToken($accessToken);

    // Refresh the token if it's expired.
    if ($client->isAccessTokenExpired()) {
        $client = refreshToken($client);
    }

    return $client;
}
开发者ID:ValentinNikolaev,项目名称:Asana-GDoc-reports,代码行数:29,代码来源:doc_list.php

示例12: getClient

function getClient()
{
    $client = new Google_Client();
    $client->setApplicationName(APPLICATION_NAME);
    $client->setScopes(SCOPES);
    $client->setAuthConfigFile(CLIENT_SECRET_PATH);
    $client->setAccessType('offline');
    $credentialsPath = CREDENTIALS_PATH;
    if (file_exists($credentialsPath)) {
        $accessToken = file_get_contents($credentialsPath);
    } else {
        $authUrl = $client->createAuthUrl();
        printf("Open the following link in your browser:\n%s\n", $authUrl);
        print 'Enter verification code: ';
        $authCode = trim(fgets(STDIN));
        $accessToken = $client->authenticate($authCode);
        if (!file_exists(dirname($credentialsPath))) {
            mkdir(dirname($credentialsPath), 0700, true);
        }
        file_put_contents($credentialsPath, $accessToken);
        printf("Credentials saved to %s\n", $credentialsPath);
    }
    $client->setAccessToken($accessToken);
    if ($client->isAccessTokenExpired()) {
        $client->refreshToken($client->getRefreshToken());
        file_put_contents($credentialsPath, $client->getAccessToken());
    }
    return $client;
}
开发者ID:atsanna,项目名称:PHP-Custom-Floorplan-for-Domoticz,代码行数:29,代码来源:gcal.php

示例13: getClient

 /**
  *  get google client
  *  @return Google_Client the authorized client object
  */
 public static function getClient()
 {
     // $scopes = implode(' ', [Google_Service_Gmail::GMAIL_READONLY]);
     /*
         $scopes = [
             'https://www.googleapis.com/auth/gmail.readonly',
             'https://www.googleapis.com/auth/gmail.modify',
             'https://www.googleapis.com/auth/gmail.send',
         ];
     */
     $scopes = ['https://mail.google.com/'];
     $clientSecretFile = conf('gmail.client_secret');
     if (!file_exists($clientSecretFile)) {
         pr('Error: client secret file not found', true);
         pr('Please create "OAuth 2.0 client IDs"');
         pr('login to https://console.developers.google.com/apis/credentials/');
         exit;
     }
     $client = new Google_Client();
     $client->setScopes($scopes);
     $client->setAuthConfigFile($clientSecretFile);
     $client->setAccessType('offline');
     // $client->setApprovalPrompt('force');
     $tokenFile = conf('gmail.access_token');
     $accessToken = self::accessToken($client, $tokenFile);
     $client->setAccessToken($accessToken);
     // Refresh the token if it's expired.
     if ($client->isAccessTokenExpired()) {
         $client->refreshToken($client->getRefreshToken());
         file_put_contents($tokenFile, $client->getAccessToken());
     }
     return $client;
 }
开发者ID:glennfriend,项目名称:gmail-import-use-api,代码行数:37,代码来源:GmailApiHelper.php

示例14: getClient

function getClient()
{
    $client = new Google_Client();
    $client->setAuthConfigFile('includes/OAuth2/client_secret.json');
    $client->setAccessToken($_SESSION['access_token']);
    return $client;
}
开发者ID:villa7,项目名称:kibbyte,代码行数:7,代码来源:query.php

示例15: __construct

 public function __construct(\Google_Client $client)
 {
     $client->setApplicationName("magicpi");
     $client->setScopes([\Google_Service_Calendar::CALENDAR_READONLY]);
     $client->setAuthConfigFile(__DIR__ . "/../config/piauth.json");
     $client->setAccessType('offline');
     $client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/auth');
     $this->client = $client;
 }
开发者ID:amazingmikeyc,项目名称:pi-lander,代码行数:9,代码来源:Authenticator.php


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