-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[server] Improve GitHub Enterprise avatars handling #8825
Conversation
…xt when avatar can't be loaded
4b353d7
to
aea5dbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was in the neighborhood and left one comment below.
Thanks for tackling this, @jankeromnes!
accountAvatarUrl: r.owner?.avatar_url, | ||
account: r.owner.login, | ||
accountAvatarUrl: r.owner.gravatar_id | ||
? `https://www.gravatar.com/avatar/${r.owner.gravatar_id}?size=128` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I really tried to find a way to get the avatar from GitHub Enterprise, but it absolutely refuses to serve the avatar unless you're logged in as a user to GHE with a browser cookie (i.e., no API call can actually serve the image, it only gives you its URL, and the avatar URL refuses any sort of token you throw at it and always redirects to interactive login).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Still, grabbing the gravatar is a small improvement step.
account: r.owner.login, | ||
accountAvatarUrl: r.owner.gravatar_id | ||
? `https://www.gravatar.com/avatar/${r.owner.gravatar_id}?size=128` | ||
: r.owner.avatar_url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: Posting this here in case it helps. GitHub, incl. GHE, allows you to fetch the user avatar by appending the username with .png
suffix, like /username.png
. But you have to be logged in for GHE to work. 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merci @jankeromnes
Description
GitHub Enterprise doesn't seem to allow cross-origin requests for user avatars, leading to a broken Gitpod UI.
Also, I initially wanted to fetch the avatars, and encode them as data URIs, however GitHub Enterprise also doesn't seem to have an API to download avatars (only browser authentication via cookies seems to work).
Thankfully, GitHub Enterprise does provide a Gravatar ID that we can use. This Pull Request does just that whenever possible, and also improves the display of avatars that cannot be found or loaded.
Related Issue(s)
Fixes #8755
Partially improves #8815
How to test
/new
Release Notes
Documentation