Cannot embed Google Drive Files in an iframe

15,559
https://docs.google.com/file/d/0B_JkNS6Wu4b5R2c0YlJSN0oyQUE/preview?usp=drivesdk

Use preview instead of edit in the URL. It will work.

Share:
15,559
Admin
Author by

Admin

Updated on June 12, 2022

Comments

  • Admin
    Admin almost 2 years

    I recently had a problem with the Google Drive API displaying my documents. We have developed a web application that is connecting to Google Drive accounts to retrieve a user's drive files, then display in an iframe the file using its embedUrl/alternateUrl.

    This has worked fine for us in the past, but suddenly files other than Google Documents stopped displaying: html files, text files, doc files... even images!

    The error I get is Refused to display 'https://docs.google.com/file/d/0B_JkNS6Wu4b5R2c0YlJSN0oyQUE/edit?usp=drivesdk' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

    I understand the error, it means that Google is preventing the display of documents outside of the Google domain, but the question is "why suddenly now", and how to circumvent it.

    If someone stumbled upon the same issue and have found a solution, I'd be glad to hear.

    Thank you kindly.

  • Tantelope
    Tantelope over 8 years
    googledrive.com/host/ID is deprecated as of August 31, 2015
  • thelastinuit
    thelastinuit almost 7 years
    Is there any way to have the whole UI Editor of Google? The preview works but I need the editor. It does work, though. It's just annoying to see the error in the inspection console, makes me think eventually it will fail.