read shared excel on sharepoint from app

Mario González 41 Reputation points
2022-09-20T08:10:52.777+00:00

using microsoft graph, and a token we need to read a shared excel in our site in sharepoint.
what are the minimal permissions and a example url to read it?
We have tried with https://graph.microsoft.com/v1.0/shares/ but received "Either scp or roles claim need to be present in the token"

Application permissions such Files.Read.All seems to be too much if we only need to access one file.

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
{count} votes

Answer accepted by question author
  1. Tong Zhang_MSFT 9,256 Reputation points
    2022-09-21T02:54:50.583+00:00

    Hi @Mario González ,

    According to my research and testing, If you want access the shared file, please use the following Graph API:

    GET /shares/{shareIdOrUrl}/driveItem  
    

    And one of the following permissions is required to call this API:
    243273-image.png

    The shareIdOrUrl parameter : please create a ShareLink for this this file , and then follow these steps to convert the ShareLink:

    1. First, use base64 encode the URL.
    2. Convert the base64 encoded result to unpadded base64url format by removing = characters from the end of the value, replacing / with _ and + with -.)
    3. Append u! to be beginning of the string.

    Please refer to this document : Accessing shared DriveItems

    Similar issue for reference: How to get the shared file with Microsoft Graph

    My test result:
    243263-01.png
    Hope it can help you. Thanks for your understanding.

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    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.



0 additional answers

Sort by: Most helpful

Your answer

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