microsoft / o365-moodle

Office 365 and Azure Active Directory plugins for Moodle
GNU General Public License v3.0
181 stars 137 forks source link

Microsoft o365 Repository: Cannot embed remote MS365 file in Moodle #1900

Open justindancer opened 2 years ago

justindancer commented 2 years ago

Hello,

When using the MS365 repository to add a file resource to a course the EMBED setting does not work.

If I add the remote file using a LINK/ALIAS and appearance as EMBED I get an error message "Error in API call.".

If I add the remote file using a MAKE A COPY and appearance as EMBED an empty embed frame is displayed and the file is downloaded.

Whether the resource is added using LINK or LOCAL it is correctly displayed if I use other values for appearance, like new window or pop-up.

Any ideas on what is preventing the EMBED working ? Is their some permission on MS that I need to set?

Many thanks,

Justin

weilai-irl commented 2 years ago

Hi @justindancer,

I acknowledge the issue. We will look into this and try to fix it in the upcoming releases.

Regards, Lai

weilai-irl commented 2 years ago

Hi @justindancer,

I have found the cause of the API error, it's caused by an error in the call to the legacy OneDrive APIs. It is in our plan to replace all calls to legacy API with calls to the new unified Graph API, and I have tried to do it for this particular case. The Graph API call was successful in that it managed to get the URL of the file, however, when trying to embedding the file in Moodle in an iframe, it gets the "refused to display" error. Basically it means the page that we are trying to embed (which is a file hosted on OneDrive) declares that it cannot be embedded on a page that's not on the same domain, and as Moodle site is on a different domain as the OneDrive file, the embedding fails.

I don't think there is a technical solution to this issue.

We will look at how to best inform users that embedding won't work in this case.

Regards, Lai