How to get all user's onedrive site url using admin account and delegated scope?

Casepoint Developer 66 Reputation points
2023-12-29T09:33:45.2866667+00:00

Hello Team,

I am using following API

So, this API is giving proper response for some user and for some user it is not working and we are getting following error:

{
    "error": {
        "code": "accessDenied",
        "message": "Access denied",
        "innerError": {
            "date": "2023-12-29T09:11:40",
            "request-id": "d24fc7a2-08a4-41dd-bcc4-c13b2f2f8335",
            "client-request-id": "0f2e2993-41dc-65c5-5c1d-b6ffb0588f61"
        }
    }
}

Note: We don't want to use application scope because we are using some other APIs which doesn't support application scope.

Can Anyone please help us in this?

Thanks & Regards

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,984 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 112.9K Reputation points MVP
    2023-12-29T18:12:17.6466667+00:00

    Using delegate permissions means you are limited to what the current user can access, and even a Global admin cannot access other user's OneDrive items by default. The only way you can make this work is to add the user in question as secondary site collection administrator to all your users' OneDrive sites. This of course comes at the cost of privacy, as the admin will then be able to access each and every file stored across all company OneDrives. If that's something you can work with, you can use one of the methods outlined here to add the secondary admin: https://petri.com/4-ways-add-secondary-administrator-onedrive-business

    Or use application permissions instead.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.