title: How to use Google Docs Viewer with puppeteer?
body: <p>I want to preview documents by Google Docs Viewer via puppeteer that runs in Node.js.
  The URL works well in browser: <br/>
  <a href="https://docs.google.com/viewer?url=https%3A%2F%2Fdocs.npmjs.com%2Fimages%2Fnpm.svg&amp;embedded=true" rel="nofollow noreferrer">https://docs.google.com/viewer?url=https%3A%2F%2Fdocs.npmjs.com%2Fimages%2Fnpm.svg&amp;embedded=true</a></p>
  
  <p>But throws error in puppeteer:</p>
  
  <pre><code>(async () =&gt; {          
          const browser = await puppeteer.launch();
          const page = await browser.newPage();           
          page.on('response', res =&gt; {
              res.text().then(text =&gt; {
                  console.log('response:', {
                      url: res.url(),
                      status: res.status(),
                      res_headers: res.headers(),
                      req_headers: res.request().headers(),
                      text: text
                  });
              });
          });
  
          await page.setBypassCSP(true);
          await page.goto(url, {waitUntil: 'networkidle0'});
          let content = await page.content();            
          await browser.close();
  
          return content;
      })();
  </code></pre>
  
  <p>Printed events:</p>
  
  <p><strong>url</strong>: <a href="https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en_US.f5JujS1eFMY.O/m=googleapis_proxy/rt=j/sv=1/d=1/ed=1/am=QQE/rs=AGLTcCNDI1_ftdVIpg6jNiygedEKTreQ2A/cb=gapi.loaded_0" rel="nofollow noreferrer">https://apis.google.com/<em>/scs/apps-static/</em>/js/k=oz.gapi.en_US.f5JujS1eFMY.O/m=googleapis_proxy/rt=j/sv=1/d=1/ed=1/am=QQE/rs=AGLTcCNDI1_ftdVIpg6jNiygedEKTreQ2A/cb=gapi.loaded_0</a>
  <br/><strong>status</strong>: 200</p>
  
  <p><strong>console</strong>: Failed to load resource: the server responded with a status of 401 ()
  <br/><strong>url</strong>: <a href="https://content.googleapis.com/drive/v2internal/about?fields=importFormats,kind&amp;key=AIzaSyDVQw45DwoYh632gvsP5vPDqEKvb-Ywnb8" rel="nofollow noreferrer">https://content.googleapis.com/drive/v2internal/about?fields=importFormats,kind&amp;key=AIzaSyDVQw45DwoYh632gvsP5vPDqEKvb-Ywnb8</a>
  <br/><strong>text</strong>: {"error": {"errors": [{"domain": "global", "reason": "required","message": "Login Required","locationType": "header","location": "Authorization"}],"code": 401,"message": "Login Required"}}</p>
  
  <p><strong>url</strong>: '<a href="https://content.googleapis.com/drive/v2internal/viewerimpressions?key=AIzaSyDVQw45DwoYh632gvsP5vPDqEKvb-Ywnb8&amp;alt=json" rel="nofollow noreferrer">https://content.googleapis.com/drive/v2internal/viewerimpressions?key=AIzaSyDVQw45DwoYh632gvsP5vPDqEKvb-Ywnb8&amp;alt=json</a>'
  <br/><strong>status</strong>: 204</p>
  
  <p><strong>console</strong>: 'Failed to load resource: the server responded with a status of 403 ()'
  <br/><strong>url</strong>: '<a href="https://content.googleapis.com/drive/v2internal/apps?fields=items(authorized,chromeExtensionIds,createInFolderTemplate,createUrl,icons(iconUrl,size,category),id,installed,kind,longDescription,name,objectType,openUrlTemplate,origins,primaryFileExtensions,primaryMimeTypes,productId,productUrl,rankingInfo,removable,requiresAuthorizationBeforeOpenWith,secondaryFileExtensions,secondaryMimeTypes,shortDescription,supportsCreate,supportsImport,supportsMultiOpen,supportsTeamDrives,type,useByDefault),kind&amp;languageCode=en-US&amp;key=AIzaSyDVQw45DwoYh632gvsP5vPDqEKvb-Ywnb8" rel="nofollow noreferrer">https://content.googleapis.com/drive/v2internal/apps?fields=items(authorized,chromeExtensionIds,createInFolderTemplate,createUrl,icons(iconUrl,size,category),id,installed,kind,longDescription,name,objectType,openUrlTemplate,origins,primaryFileExtensions,primaryMimeTypes,productId,productUrl,rankingInfo,removable,requiresAuthorizationBeforeOpenWith,secondaryFileExtensions,secondaryMimeTypes,shortDescription,supportsCreate,supportsImport,supportsMultiOpen,supportsTeamDrives,type,useByDefault),kind&amp;languageCode=en-US&amp;key=AIzaSyDVQw45DwoYh632gvsP5vPDqEKvb-Ywnb8</a>',
  <br/><strong>text</strong>: {"error": {"errors": [{"domain": "global","reason": "forbidden","message": "Forbidden"}],"code": 403,"message": "Forbidden"}},</p>
  
  <p>When I compare cookies and headers between puppeter and the browser, the headers "origin", "x-origin", "x-referrer" are the same, but the "x-chrome-connected" and "x-client-date" are missing.
  <br/>The cookie "NID" exists.</p>