Charles Finnestad
Charles Finnestad

Reputation: 11

Can't see custom attributes set on a user from their Google_Service_Directory_User object

When a custom attribute is set on a user from googles admin page I am unable to see it in their Google_Service_Directory_User object the client has this scope and is able to see the users data but no attributes are shown.

        $client->setScopes(
            [
                Google_Service_Directory::ADMIN_DIRECTORY_USER_READONLY,
                Google_Service_Directory::ADMIN_DIRECTORY_GROUP_READONLY,
            ]
        );

I would have expected it to be in the customSchemas but that is null for all the users

Upvotes: 1

Views: 532

Answers (1)

Paulloed
Paulloed

Reputation: 373

When requesting user's informations, you need to set the projection parameter to FULL when using the method users.get (projection parameter is also avaible with method users.list). Default settings to not return custom schemas. You can have more informations here (Google documentation).

You seem to be using PHP (I've never coded in PHP so I may be wrong), so the request should look like this:

$optParams = array(
  'userKey' => '[email protected]',
  'projection' => 'full', // or maybe 'FULL' ?
);
$results = $service->users->get($optParams);

If you only want the return some of the schemas, then use :

$optParams = array(
  'userKey' => '[email protected]',
  'projection' => 'custom', // or maybe 'CUSTOM' ?,
  'customFieldMask' => 'A comma-separated list of schema names'
);
$results = $service->users->get($optParams);

Upvotes: 1

Related Questions