Skip to content

PeopleService->get returns no data #5591

@iamacarpet

Description

@iamacarpet

PeopleService->get returns no data, especially when trying to get the user's photo.

Environment details

  • OS: Linux
  • PHP version: 8.1
  • Package name and version: this project -> latest

Code example

                $client = new Client([
                    'credentials' => (new GCEDWDCredentials(
                        scope: implode(' ', [
                            Directory::ADMIN_DIRECTORY_USER_READONLY,
                            PeopleService::DIRECTORY_READONLY,
                        ]),
                    ))->setSubject(env('GSUITE_ADMIN_IMPERSONATE')),
                ]);

                $user   = (new Directory($client))->users->get($this->email, ['projection' => 'full']);
                $person = (new PeopleService($client))->people->get('people/'.$user->getId(), ['personFields' => 'photos']);

                $result = [
                    'full_name' => $user->getName()->getFullName(),
                    'thumbnail' => ($person->getPhotos()[0] ?? null)?->getUrl() ?? '/propman/images/default_avatar.jpg',
                ];

This works in Go using the same credentials:

	result, err := srv.Users.Get(email).Projection("full").Do()
	if err != nil {
		return nil, fmt.Errorf("GetUserInfo: User Info API Call (%s): %s", email, err)
	}

	name := result.Name.FullName

	person, err := pplsrv.People.Get("people/" + result.Id).PersonFields("photos").Do()
	if err != nil {
		return nil, fmt.Errorf("GetUserInfo: Person Info API Call (%s:%s): %s", email, result.Id, err)
	}

        var thumbnail string
	if len(person.Photos) > 0 {
		thumbnail = person.Photos[0].Url
	} else {
		thumbnail = "/static/img/placeholder.jpg"
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions