Allow a script to access a google spreadsheet and return a JSON without authentication

Asked

Viewed 2,038 times

3

I was thinking of using a google Docs spreadsheet as persistence of a little application that I will develop.

To do so, I made the following script in the google script editor

function doGet(e) {
    var dados = SpreadsheetApp.openById(ID_DA_MINHA_SHEET).getSheetByName("Tabela 1").getDataRange();
    var res = {'Data': dados.getCell(1, 1).getValue()};
    return HtmlService.createHtmlOutput(JSON.stringify(res));
}

I’ve already set my Spreadsheet with public visibility, so that you didn’t have to ask permission to access it.

Running in the browser and logged in to my account, the script works perfectly, returns the json and everything else.

But when I’m not logged in, she always asks for authentication, even if it works when logging in with another account.

How to make it display directly without having to go through this step?

  • I don’t know I understand, the script itself asks for authentication when you try to run it without being logged in? Would you know which method call is triggering that authentication request, if it is itself openById or if it’s somewhere else? (P.S. Did you know that you can set up a file in Google Docs for only those who have the link can access - whether read or read/write? It is a preferable option to make it public, as it makes it clear that the intention is not to have this link disclosed).

  • Yes, in theory Google changed things in 2013, so that even people with no account can see a shared document as long as they have the link. Before that they needed to log in with some account, whatever it was. The following spreadsheet I shared in an article for illustration purposes and tested that opens even without login, try there: https://docs.google.com/spreadsheets/d/1fDs2bCb9YYF4m9xbu2zojCipxOoijK58EpBac_WC6go/edit#gid=0

  • This link should help -----: http://blog.concretesolutions.com.br/2014/07/como-usar-uma-planilha-como-backend-json/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.