Missing photos in Google Admin Directory Users response

末鹿安然 提交于 2020-06-17 04:59:12

问题


I'm using the Google Admin Directory Users endpoint to retrieve all the users in our company's domain. The request is working as expected and I'm receiving the full list of users.

But a large number of users are missing photos. The thumbnailPhotoUrl property is present on each user entry, but following the URL leads to

https://ssl.gstatic.com/s2/profiles/images/silhouette200.png

which is the default avatar, for a large number of our users.

However:

  • If I go into Inbox and send one of the users showing the default avatar an email, their profile pic appears when sending the email
  • And when the user logs in to our app using their company email (using Firebase Auth), their user response contains a public URL for their avatar
  • And if I log in to G Suite Admin and view our users, the majority of them have avatars. Only a small handful of users show the silhouette avatar.

Also, the docs state:

Note: In this version of the API, a photo is the user's latest Gmail Chat profile photo. This is different from the Google+ profile photo.

From the accounts we've viewed, all users have Gmail Chat/Hangout profile photos.

So it seems the users have photos associated with their account. Why are the photo URLs in the Google Admin Directory showing the default avatar? And not the user's uploaded photo?


回答1:


I ran into this today and found your question while trying to solve the problem. I think I have the answer!

The thumbnailPhotoUrl property in each of the user profiles that leads to silhouette200.png starts with https://www.google.com/s2/photos/private/ followed by a long id string.

On the other hand, any user profile that returns a valid photo (instead of redirecting to the default/anonymous photo) starts with https://www.google.com/s2/photos/public/ ... like my Google Apps/G Suite profile photo.

I discovered fairly quickly that if I am logged into my G Suite account in the browser where I try to view those thumbnail photos, they resolve as expected with actual photos instead of silhouette200.png.

So: to display G Suite user photos in a custom app, the app user needs to be logged in with a G Suite account that is authorized to read other G Suite domain users' private thumbnail photos

or

your app will need to proxy the photo request in order to return the actual thumbnail.

Of course, please do consider user privacy expectations and regulations; the fact that the profile photo is private usually indicates that the user did not set their own profile photo but had it set by some external application or sync process. (As far as I can tell, when a user sets their own profile photo using My Account or About Me, it is always made public.)



来源:https://stackoverflow.com/questions/52522003/missing-photos-in-google-admin-directory-users-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!