本文整理匯總了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']);
}