I’m trying to retrieve a list of all groups a person belongs to, but it only sometimes works.
It seems to work if a person uses an address in our org structure, but any outside addresses aren’t being found.
This code works:
<code>$url="https://admin.googleapis.com/admin/directory/v1/[email protected]";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: Bearer '.$access_token.'', 'Accept: application/json'));
$result = curl_exec($ch);
$data = json_decode($result, TRUE);
</code>
<code>$url="https://admin.googleapis.com/admin/directory/v1/[email protected]";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: Bearer '.$access_token.'', 'Accept: application/json'));
$result = curl_exec($ch);
$data = json_decode($result, TRUE);
</code>
$url="https://admin.googleapis.com/admin/directory/v1/[email protected]";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: Bearer '.$access_token.'', 'Accept: application/json'));
$result = curl_exec($ch);
$data = json_decode($result, TRUE);
But this does not:
<code>$url="https://admin.googleapis.com/admin/directory/v1/[email protected]";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: Bearer '.$access_token.'', 'Accept: application/json'));
$result = curl_exec($ch);
$data = json_decode($result, TRUE);
</code>
<code>$url="https://admin.googleapis.com/admin/directory/v1/[email protected]";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: Bearer '.$access_token.'', 'Accept: application/json'));
$result = curl_exec($ch);
$data = json_decode($result, TRUE);
</code>
$url="https://admin.googleapis.com/admin/directory/v1/[email protected]";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: Bearer '.$access_token.'', 'Accept: application/json'));
$result = curl_exec($ch);
$data = json_decode($result, TRUE);
Any ideas?
Thank you!
I’ve tried using this code and it doesn’t always work. I can pull a list of members from a group and see the person I’m looking for that way, but not when looking for a list of all groups a person belongs to.
New contributor
someguy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.