Upload file to public shared link with Microsoft Graph API ??

Thomas Rosenstein 21 Reputation points
2022-10-05T18:43:36.85+00:00

Hello,

I would like to upload a file automatically to a link that's provided by a user, specifically a link to either OneDrive or Sharepoint that contains the anonymous write permission. It would be created by the Share functionality with the "Anyone with the link can edit".

I know that probably the UploadSession API needs to be used (https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0) but it requires either Delegated or full Application permissions which I do not want to grant for this application.

Is it possible to do this without getting delegated access and without granting broad access permissions for the whole organization?

Microsoft 365 and Office SharePoint Development
Microsoft Security Microsoft Graph
{count} votes

Accepted answer
  1. Bhanu Kiran 3,616 Reputation points
    2022-10-06T03:05:29.96+00:00

    Hello @Thomas Rosenstein ,

    You can grant Microsoft Graph applications access to specific site collections. Using Sites.Selected along with the Sites permissions endpoint in Microsoft Graph allows you to set the specific site collections and access level you want to grant to individual applications.

    Please refer to this post for detailed information:
    https://learn.microsoft.com/en-us/answers/questions/698849/index.html

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it ,so that it will be helpful to the other community users. If you have any further questions about this answer, please click "Comment".

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.