How to get Sharepoint site members with Microsoft Graph API? - sharepoint

I am building an app which checks which member has access to which Sharepoint sites. How do I do that with the Microsoft Graph API?
For OneDrive I can get the user's drives by
graphServiceClient.Users[memberId].Drive.Root.Children.Request()
I would like to do that with Sharepoint sites like this
graphServiceClient.Users[memberId].Sites.Root.Children.Request()
but that is not possible. Any idea waht is the right API to get the all the Sharepoint sites the user have access to?

Related

Permissions for Azure app using Microsoft Graph to read SharePoint Online

This seems like a simple question but I'm struggling to find an answer anywhere. Help! ;-)
I'm trying to use Microsoft Graph to read SharePoint lists/libraries in a SharePoint site, however this is just for one site (for our department) amongst many on our SharePoint online. I've registered an Azure AD app (with secret etc...) and requested 'application' permissions for the Microsoft Graph ('Create, edit, and delete items and lists in all site collections') and its saying 'admin consent required' is 'yes' and its currently flagged as 'not granted for *****'.
My boss is now asking - with a worried tone ;-)
will this mean the app can basically read/write/delete on all sites in
the organisations SharePoint (not just our site) if our IT department
'consent'?
I said I don't know actually... I guess I'm not entirely clear on which permissions this is for, is it just to call the Microsoft Graph API or is it for this app to access SharePoint itself? I've searched for answers to this but I'm struggling to find anywhere that says anything about giving your app permissions in SharePoint, it all seems to be about getting permissions for the Microsoft Graph to access SharePoint.
I just want the app to have permissions to read/write lists/files in this one SharePoint site, not any others (we have loads of sites for other departments). I feel like we should be adding permissions for this app (its service principal?) somewhere on the SharePoint site we want to access, but what permissions do I need to setup and where so this app can only access this one site?
Azure AD app registration now allows for granular access to SharePoint site collection, there is a new option Sites.Selected under Azure AD App Registration - Request API Permissions - refer to https://developer.microsoft.com/en-us/graph/blogs/controlling-app-access-on-specific-sharepoint-site-collections/
Unfortunately, this feature is still missing. It is not possible to limit the permissions to only one SharePoint site. It's either access to all SharePoint sites in the organisation or none. Check out the user vote for more information: here. Microsoft is still working on providing a way to limit the access to specific resources.

Search for Content Across SharePoint Sites

Currently I'm using: /v1.0/sites/{site-id}/drive/root/search(q='{search-text}') but I would like to search across all the sites I have access to.
Is there a Microsoft Graph API which can search a keyword on all sites a user can access in SharePoint without giving site id?
There's no Graph API for a global content search at the moment.
However you can leverage the SharePoint Search API.

Microsoft Teams custom website tab retrieve information about the Team and corresponding SharePoint site

I'm looking for a way to access the corresponding Microsoft Team and SharePoint site that is created from a custom website tab. So what I have is a custom website tab added to a Microsoft Teams site. This tab is a website tab and is pointing to the custom website app that I'm building.
What I want to do is from within the custom website I want to be able to access the corresponding SharePoint site that was created from the Microsoft Team and then I want to be able to use the SharePoint client object model to interact with the document library.
You'd have to have your tab / web app provide an auth flow, and ask your user to grant access to the Graph APIs, which can be used to access that content.

Which set of APIs should be used for Office365 Sharepoint

Which set of APIs should be use to access Office365 sharepoint which includes both sharepoint2013 and sharepoint2016.
Have gone through the following APIs
1) Sharepoint2013 REST APIs(https://msdn.microsoft.com/en-us/library/office/jj860569.aspx).
2) OneDrive new APIs(https://github.com/OneDrive/onedrive-api-docs) through which we can access the Directory folder which contains directory and files. But the present focus of APIs are for OneDrive Personal and Business.
Apart from this is there any other APIs which can access the office365 sharepoint?
You could use SharePoint REST API to retrieve, update, and manage data in Sharepoint Online ,you could find code samples and videos from here.
With Graph API you could get files/users/groups ,but SharePoint sites and lists are not yet available via Microsoft Graph .
In addition ,you could also use SharePoint client object model (CSOM) to manage data in Sharepoint Online,please read below article:
Connect to SharePoint Online using Client Object Model

List Microsoft Sharepoint Sites with Microsoft Graph

I'm working with Microsoft OneDrive and Microsoft Sharepoint using Microsoft Graph, and as I understood:
Url to get file list from logged in user OneDrive is:
/v1.0/me/drive/root/children
Url to get file list from company Sharepoint Documents is:
/v1.0/drive/root/children
So my questing is:
How to list Sharepoint Sites that user is following and upload files to this Sites
This isn't possible yet. You need to use the direct SharePoint API end point to access content from SharePoint Sites.
Graph API supports accessing OneDrive, OneDrive for Business, and the document library for an Office 365 Group only.

Resources