Google Save To Drive API v3 stopped working

Viewed 222

I hope someone can help.

We have been using Google's Save to Drive button API, version 3 for quite a while to save documents generated by our system to a user's Drive. This stopped working some time last week.

The error that is thrown in the JS console is:

Uncaught ReferenceError: _createSaveToDriveWidgetApplication is not defined
at https://drive.google.com/savetodrivebutton?usegapi=1&src=(redacted URL)&filename=My%20Statement.pdf&sitename=My%20Company%20Name&origin=https%3A%2F%2F(redacted URL)&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en_GB.sedaY3Dv4HE.O%2Fam%3DwQE%2Fd%3D1%2Fct%3Dzgms%2Frs%3DAGLTcCO2t4glYwUJ-eH43TAA_offcn6l6Q%2Fm%3D__features__

So I set it up from scratch using the demo source found here on google's API docs.

My test source code looks like this:

    <!DOCTYPE html>
      <html>
        <head>
          <title>Save to Drive Demo: Explicit Render</title>
          <link rel="canonical" href="https://(redacted)">
          
           <script src="https://apis.google.com/js/platform.js"></script>
          <script>
          
            window.___gcfg = {
              parsetags: 'explicit'
            };
          </script>
         
    
        </head>
        <body>
          <a href="javascript:void(0)" id="render-link">Render the Save to Drive button</a>
          <div id="savetodrive-div"></div>
          <script>
            function renderSaveToDrive() {
              gapi.savetodrive.render('savetodrive-div', {
                src: 'https://(redacted)/go.php',
                filename: 'My Statement.pdf',
                sitename: 'My Company Name'
              });
            }
            document.getElementById('render-link').addEventListener('click', renderSaveToDrive);
          </script>
        </body>
      </html>

The redacted text are URLS, both exactly the same protocol, host, domain and port. Further, the content being retrieved is begin served with the following response headers:

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Range
Access-Control-Expose-Headers: Cache-Control, Content-Encoding, Content-Range

even though I don't need the Origin header as CORS is not used or necessary here.

I have tried Chrome, Safari, Firefox on MAC and Windows and the result is always the same - when calling gapi.savetodrive.render, it stops with the error:

Uncaught ReferenceError: _createSaveToDriveWidgetApplication is not defined

I really do not know what else to do, thus my query here. I Have Googled that error message and there is really absolutely NOTHING about it to be found.

1 Answers

This seems to be a bug.

Save to Drive button is not getting displayed when added to an HTML document. Instead, the following error is displayed in the console:

Uncaught ReferenceError: _createSaveToDriveWidgetApplication is not defined

This has been reported at least twice in Issue Tracker during the last days:

The first of these issues has been getting some traction: currently 3 people have starred it, and it has been reported internally by Google (see comment #4):

Thank you for filing this report, I was able to reproduce the behaviour so have forwarded it internally.

To anyone affected by this, I'd suggest starring this issue in order to give it more visibility.

Related