通过谷歌驱动器sdk加载文档时插入图像对话框

I am using the php google drive sdk, and programatically loading a document from Drive into a div. The document loads correctly and I can edit and save without issue. The problem occurs when I attempt to use the insert image dialog via the document menu, it just loads a blank white box.

What do I need to do in order to get the correct insert image dialog to load as if I was using the document directly from within drive? Below is the code I use to load the document:

function loadDocumentForView()
{
    $service = buildServiceAccountService("Google Drive account");

    $file = $service->files->get($_SESSION['selectedDocument']);
    $name = $file->getTitle();

    $ext = strtolower(substr(strrchr($name, "."), 1));

    if ($ext == 'doc' || $ext == 'docx')
    {
        if ($_SESSION['editSelectedDocument'] == 1)
        {
            $path = "https://docs.google.com/document/d/" . $_SESSION['selectedDocument'] . "/edit?usp=sharing&embedded=true";
        }
        else
        {
            $path = "https://docs.google.com/a/googleAccount/document/d/" . $_SESSION['selectedDocument'] . "/preview";
        }
    }
    else {
        echo "Incorrect Format";
        return;
    }

    $html = "";

        if ($_SESSION['editSelectedDocument'] == 1)
        {
            $html = $html . "<div style='text-align: left; margin-right: auto; margin-left: auto; margin-bottom: 15px; width:95%;'><input driveFile='" . $_SESSION['selectedDocument'] . "' type='button' value='Save' onclick='saveChangesAndDownload(this)' style='margin-right: 5px;' fileName='" . $_SESSION['selectedDocumentName'] ."'><input currentFile='" . $_SESSION['selectedDocument'] . "' type='button' value='Exit' onclick='exitWithoutSaving(this)'>";
            $html = $html . "<span id='saveFeedbackSpan' class='serverCallResult'></span></div>";
            $html = $html . "<object data='" . $path  . "' style='text-align:       center; margin-right: auto; margin-left: auto; width:95%; height: 99%;' id='documentViewerObject' doc='" . $_SESSION['selectedDocument'] . "'></object>";
        }

    echo $html;
}

The problem I think is that the insert image dialog uses a google PickerBuilder that uses Google's domain as the origin and if you look at the javascript console you will see a message like

Invalid 'X-Frame-Options' header encountered when loading 'https://docs.google.com/picker?protocol=gadgets&origin=https://docs.google.…NnhLX2lIv83439cgDPmc%22%7D))&rpctoken=hyerknnixivf&rpcService=bgxw5kefbo32': 'ALLOW-FROM https://docs.google.com' is not a recognized directive. The header will be ignored.
4080223570-picker_modularized_i18n_opc__iw.js:1008 Uncaught Error: Incorrect origin value. Please set it to - (window.location.protocol + '//' + window.location.host) of the top-most page

The problem is that you need to find a way to tell the picker what the origin of the document is like specifiend in the Picker API. I have the same issue and am still looking for a way to do that as well.