0

I need help on custom scheme on Google. I successfully get the user list from delegation. Below is my code.

$client = new \Google_Client();
$client->setApplicationName('xx');
$scopes = array('www.googleapis.com/auth/admin.directory.user','www.googleapis.com/auth/admin.directory.userschema');
$client->setAuthConfig('C:\Users\xx\xx\public\client_secret.json');
$client->setScopes($scopes);
$user_to_impersonate = 'xx.sg';
$client->setSubject($user_to_impersonate);

$dir = new \Google_Service_Directory($client);
$r = $dir->users->get('xxx@xx.com');
dd($r);

Userscheme have been added to Google also.

But the custom scheme I got is empty.

https://i.stack.imgur.com/0JcfZ.png

If I use projection = full in developers.google.com/admin it works.

https://i.stack.imgur.com/9s3MQ.png

Can someone help?

Jerry
  • 3
  • 2

1 Answers1

0

The documentation says:

You can fetch custom fields in a user profile by setting the projection parameter in a users.get or users.list request to custom or full.

so I would replace your line:

$r = $dir->users->get('xxx@xx.sg');

with:

$optParams = array('projection' => 'full');
$r = $dir->users->get('xxx@xx.sg', $optParams);
Peter
  • 5,501
  • 2
  • 26
  • 42