0 レビュー
0 回答
php-GoogleOauth暫定APIcustomerIDフェッチ
現在、Google Oauth 1.0を使用しており、ユーザーがドメイン管理者であるかどうかを判断しようとしています
$domain = 'abc.com';
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$gdata = new Zend_Gdata_Gapps($httpClient, $domain);
Zend_Loader::loadClass('Zend_Gdata_Query');
$gquery = new Zend_Gdata_Query('https://apps-apis.google.com/a/feeds/customer/2.0/customerId');
繰り返し処理して、customerIdが見つかったかどうかを確認します
$customerId = $exattr['value'];
その後、私たちはそうします
$gquery_str = 'https://apps-apis.google.com/a/feeds/orguser/2.0/'.$customerId.'?get=all';
orgUnitPathと電子メールを取得します。
これはすべてうまくいきますが、もちろんgoogle Oauth 1.0は廃止されており、新しいgoogleoauthに移行する必要があります。
新しいgoogleoauthを使用すると、実行することでユーザー情報を取得できます
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->addScope("https://www.googleapis.com/auth/userinfo.email");
$plus = new Google_Service_Plus($client);
if (isset($_SESSION['access_token'])) {
$me = $plus->people->get("me");
$test = $me->getEmails();
echo "<pre>";
echo var_dump($test);
echo "</pre>";
ディレクトリ管理者の場合、customerIDを判別し、上記の例のようにorgUnitを実現するにはどうすればよいですか?
Google_Service_DirectoryとGoogle_Service_Adminを試しました
$client->addScope("https://www.googleapis.com/auth/admin.directory.orgunit");
$client->addScope("https://www.googleapis.com/auth/userinfo.email");
ただし、customerIdとorgUnitをフェッチすることはできません。任意の例やヘルプをいただければ幸いです。
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。