I am accessing a Google Docs document giving the URL - DocumentApp.getActiveDocument().getURL()
and passing it in URLFetchApp
to retrieve the complete HTML content of the page. However, this way it differs from the one I get directly from browser using Inspect Element. I also tried puppeteer
to extract the same, however from the screenshot by Puppeteer I realised the html content retrieved is from the same document but without sign in.
Please help me in fetching all html content of the page after the document is signed in.
var username = Session.getActiveUser().getEmail();
var auth = ScriptApp.getOAuthToken();
var url = DocumentApp.getActiveDocument().getUrl();
var header = {"Authorization": "Bearer " + auth};
var options = { 'method':'get', 'headers':header, 'muteHttpExceptions': true };
var resp = UrlFetchApp.fetch(url, options).getContentText();
return resp;