Created
June 10, 2013 22:02
-
-
Save luissquall/5752799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "../../google-api-php-client/src/Google_Client.php"; | |
require_once "../../google-api-php-client/src/contrib/Google_DriveService.php"; | |
require_once "../../google-api-php-client/src/contrib/Google_Oauth2Service.php"; | |
require_once "../basics.php"; | |
require_once "../config.php"; | |
function buildClient($scopes, $sub = false) { | |
$key = file_get_contents(SERVICE_ACCOUNT_PKCS12_FILE_PATH); | |
$auth = new Google_AssertionCredentials( | |
SERVICE_ACCOUNT_EMAIL, | |
$scopes, | |
$key | |
); | |
$auth->sub = $sub; | |
$client = new Google_Client(); | |
$client->setUseObjects(true); | |
$client->setAssertionCredentials($auth); | |
return $client; | |
} | |
session_start(); | |
$scopes = array( | |
"https://www.googleapis.com/auth/admin.directory.group", | |
"https://www.googleapis.com/auth/admin.directory.user" | |
); | |
$client = buildClient($scopes); | |
// Option 1. Send raw HTTP request | |
$req = new Google_HttpRequest("https://www.googleapis.com/admin/directory/v1/groups?domain=domain.edu"); | |
$resp = $client::getIo()->authenticatedRequest($req); | |
$respBody = $resp->getResponseBody(); | |
pr($respBody); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment