I'm implementing OneDrive as a cloud provider in an application using the authorization code flow, so I can get access token in behalf of a user, I'm using the Graph API SDK, one of the requirements that I have it should be able to get the list of the Drives for Document Libraries that the user has access using the Graph API, but I don't know how to do it without admin consent and considering that the user that is logged in can have only read-only access or maybe owner, but probably not administration rights.
I've read a lot of possible solutions, but all of them consider that I have access to the Site ID, or Group ID, and to use any of these solutions I need to ask for admin consent permissions, so the question is, can I get all the list of a drive for a user, drives that the user already has access, without admin consent and without knowing beforehand the Sites IDs or the Group IDs?
When I login with this user account in OneDrive, I can see the Drives from Document Libraries for every Site that the user has access without Admin Consent, I need to do the same with the API.
According to your description, I assume you want to list the Document Libraries.
If we use a administrator to login, We can use the following steps to get the drives from sites.
Step1, we can use the API: /sites/root
to get all the sites in the root.
we can get the id for the every site in the root.
Step2, we can use this API: /sites/{siteId}/drives
to get the drive in one site. The siteId
parameter is the result in step1.
However, the user doesn't have access to the root site of the tenant. So it looks like that it is an legit response. Without accessing to root site, the user won't be able to query any information for that root site.