The new function in the php library loadServiceAccountJson
doesn\'t allow setting sub in the Google_Auth_AssertionCredentials
creator, so always gi
New Google API is bit different now:
$client = new Google_Client();
$client->setApplicationName("YourAppName");
$client->setAuthConfig(<JSON-Config-File-Location>);
$client->setScopes(array("https://www.googleapis.com/auth/admin.directory.user.readonly", "https://www.googleapis.com/auth/admin.directory.group.readonly"));
$client->setSubject(<User-Email-To-Impersonate>);
$service = new Google_Service_Directory($client);
$results = $service->users->listUsers(array('domain' => '<your-domain-name>'));
I'm still trying to figure out how can I get this without the need to impersonate user?