Files GraphAPI do return 403 until the file is loaded by the user

Viewed 334

As User#1, we're using this API to create a shared link: https://graph.microsoft.com/v1.0/drives/{{driveId}}/items/{{itemId}}/createLink This is successful and returns a ShareURI.

As User#2, we're using this API to get information about the item shared by User#1. https://graph.microsoft.com/v1.0/shares/{{base64ShareURI}}/driveItem

However, /driveItem returns a status code of 403 with the following body:

HTTP 403
{
    "error": {
        "code": "accessDenied",
        "message": "The sharing link no longer exists, or you do not have 
permission to access it.",
        "innerError": {
            "request-id": "73e65e0a-54b8-4722-9726-82297076276e",
            "date": "2018-11-07T16:20:03"
        }
    }
}

To prevent this 403 from happening, User#2 needs to load the ShareURI in a web browser. Once User#2 does this, then the request to the exact same URI https://graph.microsoft.com/v1.0/shares/{{base64ShareURI}}/driveItem return 200OK and the expected json body.

Why does User#2 have to load the ShareURI in a browser before being able to use Graph APIs on that ShareURI? Is there a workaround?

1 Answers
Related