0
votes

I am trying to read users calendar events using Google Calendar API. In the attendees object, Sometimes I see 'displayName' only for few participants. Most of the times the field is empty.

In the documentation it says :-

attendees[].displayName string The attendee's name, if available. Optional.

Is there a way to get all the attendees display names from the API like how we see in the Google Calendar Application?

1
Are the users all part of your domain? Another domain? @gmaila accounts?I hope this is helpful to you
Display name will only be set if the user has added a display name in their google account or the person who has invited the user has added them to google contact and given them a display name. Can you verify that they have display names set.DaImTo
@Rafa Guillermo , All the users are part of my domain.Likhith M
@DalmTo I see some of them have not set the display names yet. So if thats the case, do you suggest to use the People API instead ?... To get the attendees information? I am also trying to get the attendees profile pictures as well, which is currently not included in the response object.Likhith M

1 Answers

1
votes

Answer:

If you have the email addresses you can do a people.listDirectoryPoeple request to get their name and profile pictures.

More Information:

The people.listDirectoryPeople method of tha People API can list users, returning fields specified in the readMask parameter of the request.

A source is mandatory, so to get domain profiles, this should be set to DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE.

In order to obtain the names and photos of the users, you can make a request of the form:

curl \
  'https://people.googleapis.com/v1/people:listDirectoryPeople?readMask=photos%2Cnames%2CemailAddresses&sources=DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE&key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --compressed

Which you can then process to find the corresponding photo and name for each email address you have.

NB: If a specific user does not have a profile picture uploaded, then their respective response object will not have the photos field.

References: