How to set permissions on download URLs for One Drive and SharePoint

Matthew Lee 0 Reputation points
2024-02-16T17:25:37.25+00:00

I have been developing with the M365 Graph API and OneDrive/SharePoint. The drive Item resource type contains an instance of a download URL. What I have been trying to figure out is if there is a way of limiting access to who can download from this URL. AT the moment I am finding that this URL expires in about an hour. However for the duration of this hour this URL can be accessed without the need for further authentication. For example I could send myself a copy of the link to a phone or a different Pc and download the document. I am using an application token when requesting data from my Microsoft developer account. I have tried various ways of using OneDrive and SharePoint advanced settings to change access rights etc. Just wondering if there is a way to restrict access?. I know that using a $select filter with the GET request will remove this property however it is returned after an Upload and is also used to help facilitate a download. There are things I do not know about OneDrive and SharePoint for example administration with PowerShell.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,892 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,077 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,599 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,938 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 35,071 Reputation points Microsoft Vendor
    2024-02-19T03:07:36.6833333+00:00

    Hi @Matthew Lee, This is a sharelink for anonymous. You could set the scope and permission for the link when create it. Please refer to the following document https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http Currently there is no such api to change the scope or permission for an exist sharelink. We could only set the permission while we create the sharelink.

    --- 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.


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.