本文整理汇总了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;
}
示例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']);
}