Google admin SDK 自定义方案问题

Google admin SDK custom scheme issue

我需要有关 Google 自定义方案的帮助。 我成功地从委托中获取了用户列表。 下面是我的代码。

$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);

用户方案也已添加到 Google。

但是我得到的自定义方案是空的

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

如果我在 developers.google.com/admin 中使用 projection = full 就可以了。

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

有人可以帮忙吗?

documentation 说:

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.

所以我会替换你的台词:

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

与:

$optParams = array('projection' => 'full');
$r = $dir->users->get('xxx@xx.sg', $optParams);