Search code examples
microsoft-graph-sdks

How do i Get profile photo of specific resolution using Microsoft graph sdk


How do I get profile pic of specific resolution using graph service client sdk ? using below code I get profile pic of only one resolution i.e. 360* 360

graphServiceClient.Users["serviceprincipal"].Photo.Content.Request().GetAsync().Result

Thanks,


Solution

  • After R&D , found the answer

    var graphServiceClient= new GraphServiceClient(
                          new DelegateAuthenticationProvider(
                             (requestMessage) =>
                             {
                                 requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", response.access_token);
                                 return Task.FromResult(0);
                             }));
    
    graphServiceClient.Users["serviceprincipal"].Photos["64x64"].Content.Request().GetAsync().Result