I am trying to share a file from OneDrive using Microsoft Graph API and then allow another user to download it. However, when I attempt to download the file using the shared link, I receive a 403 Access Denied error.
User 1 creates a share link using:
POST https://graph.microsoft.com/v1.0/me/drive/items/{ItemId}/createLink
Authorization: Bearer {accessToken}
Content-Type: application/json
Request Body:
{
"type": "edit",
"scope": "anonymous"
}
Result:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.permission",
"id": "Id",
"roles": [
"write"
],
"shareId": "ShareID",
"hasPassword": false,
"link": {
"scope": "anonymous",
"type": "edit",
"webUrl": "ShareUrl",
"preventsDownload": false
}
}
now as user 2 was trying to download the link with
https://graph.microsoft.com/v1.0/shares/ShareID/driveItem/content
it returned
{
"error": {
"code": "accessDenied",
"message": "Access denied"
}
}
Troubleshooting done so far:
- Verified that the access token is valid and contains All permissions
- Confirmed that the file is accessible via the web browser when using
webUrlfrom thecreateLinkresponse - Tried creating the link with
"scope": "anonymous"and"scope": "organization"(both resulted in the same issue) - Encoded the share URL as per Microsoft documentation
- Used both delegated and application permissions, but the issue persists
Is there any permissions missing here I have given access to all Files.ReadWrite, Files.Read.All, Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All in my azure.Portal.
Is there any new API needed for this to work?
Also I tried with the organization as Scope as both user comes under the same organization.
Both users are Delegated Users.
Link For Downloading the shared File
Permissions needed in the download api
this is the permissions required in the download Api
now i will also include the Azure portal permisiion for my applications this has permisiions involving files





