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


PHP Google_Client::getScopes方法代码示例

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


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

示例1: getClient

 protected function getClient()
 {
     if (null === $this->client) {
         $this->client = new \Google_Client();
         $this->client->setAuthConfig($this->credentials);
         $this->client->setApplicationName($this->name);
         foreach ($this->services as $serviceName => $service) {
             if (!isset($service['class'])) {
                 throw new InvalidConfigException("Not set service class for service \"{$serviceName}\"");
             }
             $service['scopes'] = (array) $service['scopes'];
             if (empty($service['scopes'])) {
                 throw new InvalidConfigException("Not set scopes for service \"{$serviceName}\"");
             }
             $this->client->addScope($service["scopes"]);
         }
         $scopes = $this->client->getScopes();
         if (empty($scopes)) {
             throw new InvalidConfigException("Not set scopes for application \"{$this->name}\"");
         }
     }
     return $this->client;
 }
开发者ID:gillbeits,项目名称:yii2-google-api,代码行数:23,代码来源:GoogleApi.php

示例2: connectDrive

 public function connectDrive()
 {
     $this->autoRender = false;
     $this->loadModel('Tokens');
     // GAUTH: connect drive
     $client = new \Google_Client();
     $client->setAuthConfigFile('../client_secret.json');
     $client->addScope(\Google_Service_Drive::DRIVE);
     $client->authenticate($this->request->query['code']);
     $drive_token = $client->getAccessToken();
     $this->request->session()->write('user.drive_token', $drive_token);
     $data = ['user_id' => $this->request->session()->read('user.id'), 'scope' => implode(" ", $client->getScopes()), 'type' => 'refresh', 'token' => json_decode($drive_token)->refresh_token];
     $newToken = $this->Tokens->newEntity($data);
     $this->Tokens->save($newToken);
     return $this->redirect(['controller' => 'Player']);
 }
开发者ID:apomarinov,项目名称:cake,代码行数:16,代码来源:UsersController.php


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