I'm using an older implementation of an httpClient call to the Microsoft Graph to get a user's photo. The following code works but I'm using the Graph Client SDK now and things are done a little differently. I'm having a difficult time converting the code over as the samples and other references online don't seem to have the same methods.
Old code:
var response = await httpClient.GetAsync($"{webOptions.GraphApiUrl}/beta/me/photo/$value");
byte[] photo = await response.Content.ReadAsByteArrayAsync();
return Convert.ToBase64String(photo);
New code:
var graphServiceClient = await graphClient.GetAuthenticatedGraphClientAsync(HttpContext);
Stream photo = await graphServiceClient.Me.Photo.Content.Request().GetAsync();
I've tried examples from here and here but I'm a bit lost since ReadAsByteArrayAsync()
is not available on the new photo
object.