Search code examples
microsoft-graph-apionedrivemicrosoft-graph-sdksmicrosoft-graph-files

How to permanently get the OneDrive API download address


https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/permission_delete?view=odsp-graph-online

Note: The @microsoft.graph.downloadUrl value is a short-lived URL and can't be cached. The URL will only be available for a short period of time (1 hour) before it is invalidated.

In the tutorial, the download url expires after an hour. How do I get a permanent download address?

error Message

Sorry, something went wrong The access token has expired. It's valid from '11/11/2020 1:18:52 AM' and to '11/11/2020 2:18:52 AM'.


Solution

  • Note: The @microsoft.graph.downloadUrl value is a short-lived URL and can't be cached. The URL will only be available for a short period of time (1 hour) before it is invalidated. Removing file permissions for a user may not immediately invalidate the URL.

    The workaround was to create a share link for DriveItem and use the WebUrl as the result of the response. The file was accessed and made available for download through WebUrl. It seemed that the only way for non-tenant users to access it.

    enter image description here