Reputation: 110
I have created a dot net core application with Angular to get SharePoint data from outside of SharePoint.
I have used the below link as a reference,
https://www.c-sharpcorner.com/article/consume-sharepoint-online-csom-rest-api-with-dotnet-core-3-1/
I have successfully got data from SharePoint online list. I have a few confusion which are added below,
I will need to display SharePoint Online users' profile pictures based on user email or any alternative way on my public site page.
Also, I have added images to SharePoint Online List/Library. How can I retrieve those images on my public site page?
Can anyone help me with the same?
Thanks
Upvotes: 0
Views: 505
Reputation: 15916
Since you mentioned that you had a public site page, so I think what you need is a website which displays many users' profile picture. Hence, client credential flow may be a good option for you which has the ability to get all users' profile from graph api.
Here's the code sample to get profile picture.
using Azure.Identity;
using Microsoft.Graph;
var scopes = new[] { "https://graph.microsoft.com/.default" };
var tenantId = "your_tenant_name.onmicrosoft.com";
var clientId = "azure_ad_client_id";
var clientSecret = "client_secret";
var clientSecretCredential = new ClientSecretCredential(
tenantId, clientId, clientSecret);
var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
var user = await graphClient.Users["{user-id}"].Photo.Request().GetAsync();
You may check the response and here's the api doc.
And the sharepoint site images, you may follow this api.
/sites/{site-id}/drive/items/{item-id}
Upvotes: 0