我可以仅使用 thumbnailPhotoUrl 显示 G Suite 用户照片吗?

Can I display a G Suite User Photo with the just the thumbnailPhotoUrl?

问题

网络应用程序是否可以仅使用 thumbnailPhotoUrl 显示 G Suite 用户的个人资料图片,或者是否有必要保存和提供图片?

上下文

This Guide describes how to get the image from the Directory API. But I'm not sure how to move from the get request to an image file I can display. There is mention of the Closure Library 用于 Base64 encoding/decoding.

我想对图像使用 link,用作 img 元素的 src

我试过的

使用具有域范围委托的服务帐户的 firebase 云函数正在通过 https://www.googleapis.com/admin/directory/v1/users 检索用户数据。这 returns thumbnailPhotoUrl,我可以将 URL 粘贴到 chrome 中并查看图像。如果我与其他人分享 thumbnailPhotoUrl,他们看不到图像,而是看到剪影占位符。

注:thumbnailPhotoUrl包括/private喜欢这个:

https://www.google.com/s2/photos/private/xyz123...

这是否表明此 URL 无法在 Web 应用程序中显示图像?

您可以将 URL 的内容直接嵌入到您的 HTML 文档中。它看起来像这样:

<img width="16" height="16" alt="star" src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" />

神奇的部分是获取图像二进制数据并将其进行 base-64 编码以用于 img 标签。

上例格式:

data:[<mime type>][;charset=<charset>][;base64],<encoded data>

link 提供了更多详细信息并展示了如何执行此操作。