private function GoogleApiClient::getClient in Google API PHP Client 8
Google Client to Service.
Return value
\Google_Client Google Client
1 call to GoogleApiClient::getClient()
- GoogleApiClient::__construct in src/
Service/ GoogleApiClient.php - Callback Controller constructor.
File
- src/
Service/ GoogleApiClient.php, line 79
Class
- GoogleApiClient
- Class Google API Client Service.
Namespace
Drupal\google_api_client\ServiceCode
private function getClient() {
$client = new Google_Client();
$credentials = Json::decode($this->config
->get('credentials'));
$client
->setAuthConfig($credentials);
// $client->setApplicationName('foobar');.
// See https://developers.google.com/identity/protocols/googlescopes
$scopes = array_map('trim', explode(PHP_EOL, $this->config
->get('scopes')));
$client
->setScopes($scopes);
// $client->setScopes(['https://www.googleapis.com/auth/plus.business.manage']);
// For retrieving the refresh token.
$client
->setAccessType("offline");
// Incremental auth.
$client
->setIncludeGrantedScopes(TRUE);
// This is required when developing and in need of refresh tokens.
// $client->setApprovalPrompt("force");.
return $client;
}