I've got an issue with generating OneDrive document previews.
Background
- I'm using Business subscription with Sharepoint where I have OneDrive documents configured.
- I'm using MSAL library for React.js (https://www.npmjs.com/package/@azure/msal-react) for obtaining the User authorization token (successfully)
- The user I'm logged in has all permissions granted as well as there is an admin consent for all required permissions
- The App Registration on Azure is configured with all required permissions:
- Delegated (work or school account):
Files.Read, Files.ReadWrite, Files.ReadWrite.All, Sites.ReadWrite.All
Goal
I want to display a fully-fledged document preview on my website using React.js application.
Issue
I get the correct and successful response from the
POST /drives/{driveId}/items/{itemId}/preview
(https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_preview?view=odsp-graph-online) endpoint, from which I take a getUrl url to put into an iframe.
The iframe renders the document preview successfully with document contents BUT after a couple of seconds, the document disappears and shows the following error:
"Hmm… looks like this file doesn't have preview we can show you"
This is followed by a lot of 404 errors thrown in the debug browser console.
Video with the recording of the issue: https://share.cleanshot.com/FwpRZO