-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SharePoint: Non-core OneDrive types cannot be embedded #1
Comments
As a workaround, I looked into two things:
If we wanted to refresh either the preview URL or thumbnail, we'd have to ask the user to authenticate separately at least once (similar to how we tell a user to allow us to access their GDrive). Then, whenever either the preview URL or thumbnail expires, we would have to fetch the new URL on the user's behalf. The Azure app would also need to add additional API permissions so we can make these calls. The alternative to using the preview URL or thumbnail is simply displaying an icon of the file type with the filename. |
Apologies for the delay in this. I've put up some updates on production. Here's an example with a PDF file: The icons are exactly the ones used by OneDrive. I've tried to account for most file types for the icons such as audio, video, photo, zip, html, rtf, etc. Let me know if I'm missing any file types. Also let me know if the styling is okay. You might need to purge your browser cache and will need to re-select your file in the OneDrive block to see the changes. Also, let me know if you want me to change the "Find out how to find your shared OneDrive link" URL to something else. If you record a video on hwdsb.tv, I can change the link to that. Otherwise, I can write some placeholder documentation. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
For PDF files, once a link has been shared publicly, there are two URL. and then the subsequent link that can be located through the Open button at the top, that leverages the browser's own PDF capabilities: We couldn't somehow leverage PDF.js to display the second link could we? |
Unfortunately, that will not work for the same reason why it cannot be embedded in an iframe:
What's interesting is why SharePoint administrators cannot register their own domains to the CSP and why core OneDrive files are not affected by this CSP. |
While working on migrating our videos to SharePoint, I stumbled across a workaround to get other OneDrive items to embed from SharePoint. I only tested this method with a video, but this can probably work for other file types as well. This would require embedding two The main embed uses the following URL format:
I'm not sure if the Also I believe this method would require that downloads are not disabled for the specific OneDrive item. Needs further testing, but thought I'd document this somewhere. |
@mrjarbenne - I've got a first pass of the double You'll need to use the OneDrive block to select a video into a post. The Gutenberg live preview isn't updated yet, but if you save as a draft and view the post preview, you should be able to view the video. Older video embeds will not work as I need to save the unique ID as a block attribute. Once I get some confirmation, I'll try and get the Gutenberg live preview working to display the video and open this up to audio, images and PDFs as well. |
Cleared my cache. It's looking good from my logged in view, but logged out in a private browser window (and on a colleagues browser) I'm seeing what might be a login page from Microsoft, but it's not rendering properly: https://sandbox.commons.hwdsb.on.ca/2023/10/video-on-onedrive-test/ |
Hmm, I'm getting that as well, but after refreshing the page, the video shows up. Can you confirm if that is the case? Maybe I can add a page refresh after the initial page load is done so the cookies are set before the embed is ready to show up? |
Yes. Refreshing the page seems to bring it to life. |
I made a little error when rendering the second |
I think that fixed it. It seems to be working nicely now. |
I've opened up the double iframe technique to audio, images and PDFs. I still need to get the Gutenberg preview working with this new technique, so for now, you will have to save as a draft or publish the post to view the change on the frontend. I found one niggle while testing when logged out. If you are viewing a few, different embeds on the same page when logged out, only one of the embeds will render correctly unless you refresh the page again. You can test at |
Here's a post with some test content: https://sandbox.commons.hwdsb.on.ca/2023/10/embed-test/ When the post first loaded only the bottom option appeared. When I refresh (multiple times) only the second to last option is available: It does look great when logged in. |
The first embed uses the "Anyone with the link can view" sharing link generated by OneDrive. The sharing URL generally resembles something like: hxxps://XXX.sharepoint.com/:v:/g/personal/XXX/SOMEID. Embedding the sharing link helps to set the necessary authentication cookies needed to view the main embed. This iframe is hidden from display. The main embed uses the following URL format: hxxps://XXX.sharepoint.com/personal/XXX/_layouts/15/embed.aspx?UniqueId=XXX. UniqueId is a parameter we need to query OneDrive for and is not the same as SOMEID from the first embed. This is an undocumented way of embedding media from SharePoint. Experimental. See #1.
When using SharePoint/Office 365, it appears items that are not a core OneDrive type (Word, Powerpoint, Excel, Visio) will not embed properly due to a cross-domain iframe request restriction:
So basically any file like an image, audio or PDF will not work
without further SharePoint configuration. This also includes OneNote.There's a SharePoint UserVoice suggestion here that is worth keeping an eye on: https://sharepoint.uservoice.com/forums/329214-sites-and-collaboration/suggestions/37212052-ability-to-use-frame-iframe-object-embed
The text was updated successfully, but these errors were encountered: