Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Office 365 profile avatar picture

We have a system that will integrate in some ways with Office 365, and we would like to use the profile picture set by the user in the Office 365 system, rather than storing this image/reference ourselves. However, I can't find any way of accessing this image (for example via an email address) from outside Office 365.

To put it another way, is Office 365 capable of serving up the profile picture of the user in a similar way to Gravatar?

like image 250
Miika L. Avatar asked Sep 18 '12 12:09

Miika L.


People also ask

Who can see my Microsoft 365 profile picture?

Yes, the picture is not visible by external people and only can be seen by internal users in an email.

How do I upload a picture to Office 365?

Select the circle in the upper-right corner of the page that shows your initials or an icon of a person. In the My accounts window, select the circle that shows your initials or an icon of a person. In the Change your photo pop-up window, select Upload a new photo, and then select and upload your photo.

Why can't I change my Office 365 profile picture?

Choose your profile photo and then choose Another user. Select the user you want to change photo and click OK. Under Account, choose Edit information. Choose Change and upload photo.


2 Answers

You can also use the Office365 Unified API (Preview) https://msdn.microsoft.com/office/office365/APi/photo-rest-operations

And use as Base64 Encoded Image. Please pay attention on the changed API since the last Update.

Here my code:

 HttpClient client = new HttpClient();
 HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get,
       "https://outlook.office.com/api/beta/me/photos('96x96')/$value");
        request.Headers.Add("ACCEPT", "image/*");
        request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
        HttpResponseMessage response = await client.SendAsync(request);
        byte[] byteArray = await response.Content.ReadAsByteArrayAsync();

        string base64ImageRepresentation = Convert.ToBase64String(byteArray);

        if (!response.IsSuccessStatusCode && response.StatusCode >= HttpStatusCode.BadRequest)
        {
            return string.Empty;
        }

        return base64ImageRepresentation;
like image 133
sergej Avatar answered Oct 02 '22 08:10

sergej


You can use the Graph API to get the User Entity record, which has the profile picture

http://msdn.microsoft.com/en-us/library/hh974483.aspx - see thumbnailPhoto field.

For REST API info: http://msdn.microsoft.com/en-us/library/hh974478.aspx

like image 32
Dragos Bobolea Avatar answered Oct 02 '22 08:10

Dragos Bobolea