Wednesday 11 November 2020

How to fetch user profile image from Azure Active Directory from SharePoint Online?

 In this article, How to show user profile image from azure environment in SharePoint Online.


REST API call provides profile picture of Office 365 users. But I want to pull profile image for SharePoint Online user from Azure Active Directory.

we have option to retrieve using Graph API by Microsoft

below code have used Microsoft Graph API to fetch user's profile image from delve then please share some snippets.


In Graph API, you can use the below endpoint to fetch photo from Azure AD:


https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/photo/$value


 user's email address as peter@CIE45879.onmicrosoft.com, then your url will be:


https://graph.microsoft.com/v1.0/users/peter@CIE45879.onmicrosoft.com/photo/$value


we have to allow permission to retrive the tenant , we need to set the app permission as


Profile photo of any user in the tenant including the signed-in user - User.ReadBasic.All; User.Read.All; User.ReadWrite.All


No comments:

Post a Comment