1

I have to display all SharePoint Online user's profile information including profile picture on a page in SharePoint Online.

Here some of user has profile picture set in Office 365, while some users have profile picture added in Azure Active Directory.

I am able to use REST API call but it gives me the profile picture of Office 365 users. But I want to pull profile image for SharePoint Online user from Azure Active Directory.

How I can achieve this?

One way is using Graph API by Microsoft, But its usage is confusing me. If any one have used Microsoft Graph API to fetch user's profile image from delve then please share some snippets.

3

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

So, for example, you have user's email address as alans@CIE493742.onmicrosoft.com, then your url will be:

https://graph.microsoft.com/v1.0/users/alans@CIE493742.onmicrosoft.com/photo/$value

To get this, you 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

To test your endpoints, sign in to graph explorer and check

Graph explorer

Azure AD Get photo

  • Here I will have user email address in javascript array. Also I want to know more about authentication part. Also I don't want to see any login window again. – Trimantra Software Solution May 17 '17 at 7:02
  • 1
    Authentication is another beast - you need to implement adal js or angular adal js if using angular code. You also need to register your app in Azure with the permission. Check these links - Authenticating with adal js and Using sharepoint with Adal – Gautam Sheth May 17 '17 at 7:08
  • I am using from SharePoint online page. So, Once I already logged in. But it shows unauthorized – Trimantra Software Solution May 17 '17 at 7:22
  • That's expected. Please go through the above links. You need to authenticate to azure AD. Setup the azure app and implement adal js, only after that will you get the data. – Gautam Sheth May 17 '17 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.