Appscript webapp returns authentication error when an unauthenticated google account is logged in another tab

38 Views Asked by At

I have a google AppScript project deployed as Web app. When single authenticated account is logged-in DoGet method works fine. But If any user get logged into another unauthenticated google account in another tab I start getting authentication error from DoGet call from the authenticated account tab.

I am accessing my AppScipt web app via google chrome extension and making http calls from background.

here is how I am making the request from extension background

const onRuntimePostMessage: any = (request: any, sender: any, __: any): void => {
        if (!request.message || !sender.tab.id || request.message === 'changePopupDOM') {
            return;
        }
        const ts: number = Date.now();
        switch (request.message) {
            case 'pluginReq':
                const msgId: string = request.data.msgId;
                CwZ.ajax({
                    type: 'GET',
                    url: request.data.url,
                    success: (data: any, status: any, _xhr: any): void => {
                        data['msgId'] = msgId;
                        chrome.tabs.sendMessage(sender.tab.id, {
                            method: 'pluginReq',
                            data: data,
                            msgId: msgId,
                        });
                    }
                });
                break;
        }
    }

snippet from Google AppScript DoGet method

function doGet(options) {
    try {
        Logger.log('doGet');
        var params = options.parameters;
        var opt = params['opt'][0];
        var retVal = void 0;
        var docId = params['docId'];
        if (docId) {
            switch (opt) {
                case 'gl': {
                    var doc = DocumentApp.openById(docId); // doc is an HTML Element
                    var locator = 'false';
                    if (params['locator']) {
                        locator = params['locator'];
                    }
                    var pageLayer = new _services_page_layer__WEBPACK_IMPORTED_MODULE_1__.PageLayer();
                    var links = pageLayer.getPageData(doc, locator);
                    var json = JSON.stringify(transformLinksToId(links));
                    retVal = ContentService.createTextOutput(json).setMimeType(ContentService.MimeType.JSON);
                    break;
                }
                
            }
        }
        return retVal;
    }
    catch (ex) {
        Logger.log(ex);
    }
}

I tried changing requests methods like fetch and ajax but getting same issue.

0

There are 0 best solutions below