Jeszcze raz logowanie przy użyciu google sheet

Let me see your aia project, perhaps something there...

queryEmailPass.aia (2.2 KB)
This is quite the same as you sent me.

and it works for me (it is using my script url)

You need to create your own script aligned with your spreadsheet

Then send over the full script and aia project

Again, ensure that your script is correctly deployed and you use the correct script url.

function doPost(e) {

return authenticate(e);

}

function authenticate(e) {

if (e.parameter.func == "Login") {

//var ss = SpreadsheetApp.getActive();

//var sh = ss.getSheetByName("Sheet1");

  var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1-WJLtFfREfV-8N6PC4bBSBX-3-7iFZV95nzToWwHEHQ/edit#gid=0");

  var sh = ss.getSheetByName("Sheet1");

var email = e.parameter.email;

var password = e.parameter.password;

var message = "";

var rg = sh.getName() + "!" + sh.getDataRange().getA1Notation();

var sql = '\"Select A,B,C where B =\'' + email + '\'\"';

var qry = '=IFERROR(query(' + rg + ',' + sql + '),"")';

var ts = ss.insertSheet();

var setQuery = ts.getRange(1,1).setFormula(qry);

var getResult = ts.getDataRange().getValues();

var getPWD = ts.getRange(2,3).getValue();

var getFullName =ts.getRange(2,1).getValue();

ss.deleteSheet(ts);

if ( getResult != "" )  {

 if ( getPWD == password ) {

   message = getFullName;

 }

 else  {

   message = "ERPWD";

 }

}

 else {

   message = getResult;

 }

return ContentService.createTextOutput(message);

}

}

queryEmailPass (2).aia (2.2 KB)

Can you confirm that you have the escape \ characters in your script on this line:

var sql = '\"Select A,B,C where B =\'' + email + '\'\"';

(they could have been lost when you posted your script on to the topic)

Ah, I have edited your post, I see them now :slight_smile:

I too, am at a loss as to why this is not working for you.

Go onto your spreadsheet
Create a new Sheet
in cell A1 put the following:

=query(Sheet1!A1:D5,"Select A where B = 'piotrpio@gmail.com'")

It should return:

FullName
Piowar96

this is what the script should be doing....

Could you also please confirm that you have followed all the steps here:

and that your script is set to be accessed by Anyone and not Anyone with a google account

U mnie zwraca #ERROR!

Yes .I confirm

Well, if that doesn't work, nothing else will...

You could try a completely new spreadsheet ?

I used your script from query any google sheet. I do not understand while this scrip works fine with the line no 14 but failed with the number 15. Please find ia file and script.nowy_test.aia (2.2 KB)

function doGet(e) {

  return queryAnySheet(e);

}

function doPost(e) {

  return queryAnySheet(e);

}

function queryAnySheet(e) {

 var ss = SpreadsheetApp.openById('1-WJLtFfREfV-8N6PC4bBSBX-3-7iFZV95nzToWwHEHQ');

  var sh = ss.getSheetByName("Sheet1");

 var rg = sh.getName() + "!" + sh.getDataRange().getA1Notation();

 

 var email = e.parameter.email;

var sql= 'Select A,B,C';

//var sql = '\"Select A,B,C where B =\'' + email + '\'\"';

var qry = '=query(' + rg + ';\"' + sql + '\";1)';

 var ts = ss.insertSheet();

 var setQuery = ts.getRange(1,1).setFormula(qry);

 var getResult = ts.getDataRange().getValues();

 ss.deleteSheet(ts);

 var outString = '';

  for (var row=1;row < getResult.length; row++) {

 outString += getResult[row].join(',') + '\n';

 }

 return ContentService.createTextOutput(outString);

}

The original script was designed for the setting of the query from the app.

To help you, when you post code use three backticks above and below your code:

```
code here

```

Could yo be more specific. Sorry, I do not understand what you mean

Sorry two separate things:

In answer to your question as to why the original script works:

To help you successfully post script code on the community:

when you post code use three backticks above and below your code:

```
code here

```