# אכלוס אוואטרים של משתמשים עם Microsoft Graph Oauth2

**URL:** <https://meta.discourse.org/t/populating-user-avatars-with-microsoft-graph-oauth2/191074>\
**Category:** SSO\
**Created:** [20 במאי,‏ 2021,‏ 1:44pm UTC](https://meta.discourse.org/t/populating-user-avatars-with-microsoft-graph-oauth2/191074 "2021-05-20T13:44:19Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![adamgpope](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamgpope/32/121658_2.png) [@adamgpope](https://meta.discourse.org/u/adamgpope)\
**Post date:** [21 במאי,‏ 2021,‏ 11:18am UTC](https://meta.discourse.org/t/populating-user-avatars-with-microsoft-graph-oauth2/191074/3 "2021-05-21T11:18:26Z")

</div>

Thanks for checking that out, @david. Prompted me to see if I could ‘fetch’ it into the user JSON, appears the [OData expand query parameter](https://docs.microsoft.com/en-us/graph/query-parameters#error-handling-for-query-parameters) isn’t supported for the photo though - which does come through as a URL if you append /$value to it:

> …you cannot use `$expand` on the `user/photo` relationship.

I couldn’t figure out a way to reverse that; so instead of `https://graph.microsoft.com/beta/me?$expand=photo` going something like `https://graph.microsoft.com/beta/me/photo/$value?$expand=mail,displayName`. Splutter, toys out of pram, rant.

Perhaps we could use the ‘mail’ location in the JSON data to construct the URL to the photo, which is consistently:

> [https://tenant-my.sharepoint.com/User%20Photos/Profile%20Pictures/adam\_pope\_arup\_com\_LThumb.jpg](https://tenant-my.sharepoint.com/User%20Photos/Profile%20Pictures/adam_pope_arup_com_LThumb.jpg)

..so could we concatenate the three elements in the field with the right syntax? My numpty attempt here didn’t work, unsurprisingly:

“[https://tenant-my.sharepoint.com/User%20Photos/Profile%20Pictures/](https://tenant-my.sharepoint.com/User%20Photos/Profile%20Pictures/)” & mail & “\_LThumb.jpg”

…or maybe another way - I’m clearly grasping at straws here - would be to add the photo endpoint to the oauth2 user json url field with something like:

[https://graph.microsoft.com/v1.0/me?https://graph.microsoft.com/v1.0/me/photo](https://graph.microsoft.com/v1.0/me?https://graph.microsoft.com/v1.0/me/photo)

---

_[View the full topic](https://meta.discourse.org/t/populating-user-avatars-with-microsoft-graph-oauth2/191074)._
