External OneDrive items access

Martin Tomek 1 Reputation point
2022-12-07T16:33:34.387+00:00

In Azure Portal (business account) we created an app for OneDrive files and folders management via Graph API and granted both delegated and application permissions for required actions (create folder, list folder, upload file, etc.).

In some cases we need to use application permissions for these. When we try to e.g. list the folder stored on the drive within the same Azure AD, they all succeed.

But we need the app to be used from the external accounts as well. When I try to list the folder on my personal drive I get following error:
"The provided drive id appears to be malformed, or does not represent a valid drive."
(using endpoint https://graph.microsoft.com/v1.0/drives/{drive-id}/items/root/children)

  • The drive ID is correct (returned from /me/drive endpoint while using delegated permissions)
  • The app was allowed to do all the stuff for my personal account
  • Permissions are configured (Directory.ReadWrite.All, Files.ReadWrite.All, Sites.ReadWrite.All, User.ReadWrite.All)
  • Supported account types are "Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)"

Is there anything else where the app might be limited not to reach the external drive items? Or is the problem anywhere else?
Thank you for any advice!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,715 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,686 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 31,681 Reputation points Microsoft Vendor
    2022-12-08T02:51:56.31+00:00

    Hi @Martin Tomek
    To share the item with external users, you will need to learn about external sharing features of Microsoft. Please refer to following document
    https://learn.microsoft.com/en-us/sharepoint/external-sharing-overview
    After share the item with external users, you can access the item by the graph api

    GET /shares/{shareIdOrEncodedSharingUrl}  
    

    For more details you can refer to the following document
    https://learn.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=http


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.